[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-2257) Raise a session expired and new session event on occurence

Florian Fray (JIRA) jira-events at lists.jboss.org
Wed Jan 9 05:10:02 EST 2008


    [ http://jira.jboss.com/jira/browse/JBSEAM-2257?page=comments#action_12394270 ] 
            
Florian Fray commented on JBSEAM-2257:
--------------------------------------

Pete, the Lifecycle.beginSession and .endSession is also triggered by the SeamListener, 
which is implementing javax.servlet.http.HttpSessionListener.
So it is reacting precisely on Session-creation and -destruction.

You can approve this by following the code in org.jboss.seam.servlet.SeamListener.

Here's the related code for comfort-reasons:
org.jboss.seam.servlet.SeamListener
###
   ...
   public void sessionCreated(HttpSessionEvent event) 
   {
      ServletLifecycle.beginSession( event.getSession() );
   }
   
   public void sessionDestroyed(HttpSessionEvent event) 
   {
      ServletLifecycle.endSession( event.getSession() );
   }
   ...
###

org.jboss.seam.contexts.ServletLifecycle
###
...
   public static void beginSession(HttpSession session)
   {
      Lifecycle.beginSession( new ServletSessionMap(session) );
   }

   public static void endSession(HttpSession session)
   {
      Lifecycle.endSession( new ServletSessionMap(session) );
   }
...
###



> Raise a session expired and new session event on occurence
> ----------------------------------------------------------
>
>                 Key: JBSEAM-2257
>                 URL: http://jira.jboss.com/jira/browse/JBSEAM-2257
>             Project: JBoss Seam
>          Issue Type: Feature Request
>          Components: Security
>    Affects Versions: 2.0.0.GA
>            Reporter: Jacob Orshalick
>         Assigned To: Shane Bryzak
>            Priority: Minor
>             Fix For: 2.0.x
>
>
> You have to make some assumptions here, but you can basically notify the user when the server session has ended with the following in a PhaseListener:
> Code:
> @Observer("org.jboss.seam.beforePhase")
> public void beforePhase(PhaseEvent event)
> {
>   if(event.getPhaseId() == PhaseId.RESTORE_VIEW)
>   {
>     HttpServletRequest request =
>       (HttpServletRequest) FacesContext.getCurrentInstance()
>         .getExternalContext().getRequest();
>             
>     if(request.getRequestedSessionId() != null 
>            && request.getSession().isNew())
>        Events.instance().raiseEvent("org.jboss.seam.sessionExpired");
> ...	
> Based on general cookie settings this will raise the event when the user still has the browser window open, the http session expired, and the user tries to access the app. If the user closes and reopens the browser to start the application, the event will not be raised.  This of course makes the assumption that cookies expire when the browser session is ended (which is generally the case).
> The org.jboss.seam.newSession event would simply change the condition to:
>    if(request.getRequestedSessionId() == null 
>            && request.getSession().isNew())
>       Events.instance().raiseEvent("org.jboss.seam.newSession");
> This is generally useful for user notification on the login screen.  Please see the forum reference for more information.  Thanks.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list