-
1. Re: Session Listener: @Startup for session scoped component
jameswoodward Mar 2, 2006 9:03 AM (in response to liudan2005)To trigger a method to run when a session scoped component is created use the @Create annotation.
@Create
public void init() {
.....
} -
2. Re: Session Listener: @Startup for session scoped component
liudan2005 Mar 2, 2006 10:04 AM (in response to liudan2005)@Create method only gets trigger when your component is referenced in a jsf page and the page is requested by the user. If your site has many entrances, this is gonna be a problem.
-
3. Re: Session Listener: @Startup for session scoped component
gavin.king Mar 2, 2006 10:22 AM (in response to liudan2005)"liudan2005" wrote:
At moment, if you have @Startup in your class, your component gets initialised no matter it's session scoped or application scoped. In some occasions, you might want to do some initialization and outject the component when session is created. For example, you might need to retrive the user info for personalized home page. In this case, it would be nice to have a session scoped component that gets trigger when session is created. i.e. a session scoped component with @Startup annotation should be triggered only when a new session is created.
Had a look at seam source code and I think it should be easy to implement this by adding some code to SeamListener and Lifecycle.
I would be happy to accept a patch that implemented this. -
4. Re: Session Listener: @Startup for session scoped component
liudan2005 Mar 2, 2006 11:55 AM (in response to liudan2005)I've submitted the patch.
http://jira.jboss.com/jira/browse/JBSEAM-148 -
5. Re: Session Listener: @Startup for session scoped component
gavin.king Mar 2, 2006 11:57 AM (in response to liudan2005)Cool, thanks.
-
6. Re: Session Listener: @Startup for session scoped component
xtia004 Aug 3, 2006 5:17 PM (in response to liudan2005)I applied @Startup to a class and @Create to a method of the class. At the method, I want to do something and set a component to session scope. I tried: @In Context sessionContext;, no matter set create and requested to true or not, sessionContext is always null. I also tried @Out(scope=ScopeType.SESSION) private Operator currentUser;, no matter set requested to true or not, it is not outjected to session. I guess at the moment, the session context is not instanced. What to do if I want to initialize something right after a session created but before any other actions taken.
-
7. Re: Session Listener: @Startup for session scoped component
gavin.king Aug 3, 2006 5:21 PM (in response to liudan2005)Right, there is no session context (or any HttpSession) at web-app initialization time.
(Assuming that the component with the @Startup annotation is application-scoped.) -
8. Re: Session Listener: @Startup for session scoped component
xtia004 Aug 3, 2006 5:26 PM (in response to liudan2005)Thanks, is or will be there a resolution to deal with this case?
-
9. Re: Session Listener: @Startup for session scoped component
pmuir Aug 4, 2006 5:06 AM (in response to liudan2005)What session do you expect to be available when the web app is initialising?
-
10. Re: Session Listener: @Startup for session scoped component
gavin.king Aug 4, 2006 10:25 AM (in response to liudan2005)No, no resolution, what you are asking for makes no sense.