-
1. Re: Call method on http session creation
asookazian Aug 12, 2009 9:59 PM (in response to frer)You can try something like this:
@Name("foo") @Scope(ScopeType.SESSION) @Startup public class Foo { @Logger private Log log; @Out(required=false) private String s1; @Create public void bar(){ log.info("in bar()"); //set your variables and outject s1 = "baz"; } }
output:
12:53:24,731 INFO [EARDeployer] Started J2EE application: file:/C:/java/jboss-4.2.3.GA/server/default/deploy/jboss-seam-booking.ear/ 12:53:30,715 INFO [TestOnStartupSession] in bar()
There is also this event:
org.jboss.seam.security.loginSuccessful which is raised when a new session is created and authentication occurs
that you can observe using @Observer in a session-scoped Seam component.
-
2. Re: Call method on http session creation
frer Aug 13, 2009 3:55 PM (in response to frer)THank you for your reply Arbi.
I'll give it a try but I don't think its what I'm looking for. I want the method to be called when a user accesses the site (so his HTTP session is created). The user will NOT have logged in yet but I still want a method to be called so I can check some of his settings and customize the application (without his user info but with the http meta info)).
Do you know how this would be possible?
-
3. Re: Call method on http session creation
frer Aug 13, 2009 4:22 PM (in response to frer)Ah you were right! Sorry about that I thought the @Startup would be called only on application startup....
It worked great!
Thanks for your help
-
4. Re: Call method on http session creation
asookazian Aug 14, 2009 12:31 AM (in response to frer)If you use @Application and @Startup at the class level and @Create at the method level, that method will execute when the app is deployed (i.e. prior to session creation).