org.apache.myfaces.orchestra.conversation.servlet
Class ConversationManagerSessionListener

java.lang.Object
  extended by org.apache.myfaces.orchestra.conversation.servlet.ConversationManagerSessionListener
All Implemented Interfaces:
EventListener, javax.servlet.http.HttpSessionActivationListener, javax.servlet.http.HttpSessionAttributeListener, javax.servlet.http.HttpSessionListener, javax.servlet.ServletContextListener

public class ConversationManagerSessionListener
extends Object
implements javax.servlet.ServletContextListener, javax.servlet.http.HttpSessionListener, javax.servlet.http.HttpSessionAttributeListener, javax.servlet.http.HttpSessionActivationListener

An http session listener which periodically scans every http session for conversations and conversation contexts that have exceeded their timeout.

If a web application wants to configure a conversation timeout that is shorter than the http session timeout, then this class must be specified as a listener in the web.xml file.

A conversation timeout is useful because the session timeout is refreshed every time a request is made. If a user starts a conversation that uses lots of memory, then abandons it and starts working elsewhere in the same webapp then the session will continue to live, and therefore so will that old "unused" conversation. Specifying a conversation timeout allows the memory for that conversation to be reclaimed in this situation.

This listener starts a single background thread that periodically wakes up and scans all http sessions to find ConversationContext objects, and checks their timeout together with the timeout for all Conversations in that context. If a conversation or context timeout has expired then it is removed.

This code is probably not safe for use with distributed sessions, ie a "clustered" web application setup.

See ConversationWiperThread for more details.


Constructor Summary
ConversationManagerSessionListener()
           
 
Method Summary
 void attributeAdded(javax.servlet.http.HttpSessionBindingEvent event)
           
 void attributeRemoved(javax.servlet.http.HttpSessionBindingEvent event)
           
 void attributeReplaced(javax.servlet.http.HttpSessionBindingEvent event)
           
 void contextDestroyed(javax.servlet.ServletContextEvent event)
           
 void contextInitialized(javax.servlet.ServletContextEvent event)
           
 void sessionCreated(javax.servlet.http.HttpSessionEvent event)
           
 void sessionDestroyed(javax.servlet.http.HttpSessionEvent event)
           
 void sessionDidActivate(javax.servlet.http.HttpSessionEvent se)
          Run by the servlet container after deserializing an HttpSession.
 void sessionWillPassivate(javax.servlet.http.HttpSessionEvent se)
          Run by the servlet container before serializing an HttpSession.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConversationManagerSessionListener

public ConversationManagerSessionListener()
Method Detail

contextInitialized

public void contextInitialized(javax.servlet.ServletContextEvent event)
Specified by:
contextInitialized in interface javax.servlet.ServletContextListener

contextDestroyed

public void contextDestroyed(javax.servlet.ServletContextEvent event)
Specified by:
contextDestroyed in interface javax.servlet.ServletContextListener

sessionCreated

public void sessionCreated(javax.servlet.http.HttpSessionEvent event)
Specified by:
sessionCreated in interface javax.servlet.http.HttpSessionListener

sessionDestroyed

public void sessionDestroyed(javax.servlet.http.HttpSessionEvent event)
Specified by:
sessionDestroyed in interface javax.servlet.http.HttpSessionListener

attributeAdded

public void attributeAdded(javax.servlet.http.HttpSessionBindingEvent event)
Specified by:
attributeAdded in interface javax.servlet.http.HttpSessionAttributeListener

attributeRemoved

public void attributeRemoved(javax.servlet.http.HttpSessionBindingEvent event)
Specified by:
attributeRemoved in interface javax.servlet.http.HttpSessionAttributeListener

attributeReplaced

public void attributeReplaced(javax.servlet.http.HttpSessionBindingEvent event)
Specified by:
attributeReplaced in interface javax.servlet.http.HttpSessionAttributeListener

sessionDidActivate

public void sessionDidActivate(javax.servlet.http.HttpSessionEvent se)
Run by the servlet container after deserializing an HttpSession.

This method tells the current ConversationWiperThread instance to start monitoring all ConversationManager objects in the deserialized session.

Specified by:
sessionDidActivate in interface javax.servlet.http.HttpSessionActivationListener
Since:
1.1

sessionWillPassivate

public void sessionWillPassivate(javax.servlet.http.HttpSessionEvent se)
Run by the servlet container before serializing an HttpSession.

This method tells the current ConversationWiperThread instance to stop monitoring all ConversationManager objects in the serialized session.

Specified by:
sessionWillPassivate in interface javax.servlet.http.HttpSessionActivationListener
Since:
1.1


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.