You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/02/12 21:11:30 UTC

svn commit: r627073 - /myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/servlet/ConversationManagerSessionListener.java

Author: skitching
Date: Tue Feb 12 12:11:27 2008
New Revision: 627073

URL: http://svn.apache.org/viewvc?rev=627073&view=rev
Log:
Replace tabs with spaces only

Modified:
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/servlet/ConversationManagerSessionListener.java

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/servlet/ConversationManagerSessionListener.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/servlet/ConversationManagerSessionListener.java?rev=627073&r1=627072&r2=627073&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/servlet/ConversationManagerSessionListener.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/servlet/ConversationManagerSessionListener.java Tue Feb 12 12:11:27 2008
@@ -39,14 +39,14 @@
  * <p>
  * 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. 
+ * as a listener in the web.xml file.
  * <p>
  * 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. 
+ * memory for that conversation to be reclaimed in this situation.
  * <p>
  * This listener starts a single background thread that periodically wakes
  * up and scans all http sessions to find ConversationContext objects, and
@@ -61,123 +61,123 @@
  * for more details.
  */
 public class ConversationManagerSessionListener
-	implements HttpSessionAttributeListener, HttpSessionActivationListener, ServletContextListener
+    implements HttpSessionAttributeListener, HttpSessionActivationListener, ServletContextListener
 {
-	private final Log log = LogFactory.getLog(ConversationManagerSessionListener.class);
-	private final static long DEFAULT_CHECK_TIME = 5 * 60 * 1000; // every 5 min
+    private final Log log = LogFactory.getLog(ConversationManagerSessionListener.class);
+    private final static long DEFAULT_CHECK_TIME = 5 * 60 * 1000; // every 5 min
 
-	private final static String CHECK_TIME = "org.apache.myfaces.orchestra.WIPER_THREAD_CHECK_TIME"; // NON-NLS
+    private final static String CHECK_TIME = "org.apache.myfaces.orchestra.WIPER_THREAD_CHECK_TIME"; // NON-NLS
 
-	private ConversationWiperThread conversationWiperThread;
+    private ConversationWiperThread conversationWiperThread;
 
-	public void contextInitialized(ServletContextEvent event)
-	{
-		long checkTime = DEFAULT_CHECK_TIME;
-		String checkTimeString = event.getServletContext().getInitParameter(CHECK_TIME);
-		if (checkTimeString != null)
-		{
-			checkTime = Long.parseLong(checkTimeString);
-		}
-
-		conversationWiperThread = new ConversationWiperThread(checkTime);
-		conversationWiperThread.start();
-		log.debug("initialised");
-	}
-
-	public void contextDestroyed(ServletContextEvent event)
-	{
-		conversationWiperThread.interrupt();
-		conversationWiperThread = null;
-	}
-
-	public void attributeAdded(HttpSessionBindingEvent event)
-	{
-		// Somebody has called session.setAttribute
-		if (event.getValue() instanceof ConversationManager)
-		{
-			ConversationManager cm = (ConversationManager) event.getValue();
-			conversationWiperThread.addConversationManager(cm);
-		}
-	}
-
-	public void attributeRemoved(HttpSessionBindingEvent event)
-	{
-		// Either someone has called session.removeAttribute, or the session has been invalidated.
-		// When an HttpSession is invalidated (including when it "times out"), this method is
-		// called once for every attribute in the session; note however that at that time the
-		// session is invalid so in some containers certain methods (including getId and
-		// getAttribute) throw IllegalStateException. 
-		if (event.getValue() instanceof ConversationManager)
-		{
-			ConversationManager cm = (ConversationManager) event.getValue();
-			conversationWiperThread.removeConversationManager(cm);
-		}
-	}
-
-	public void attributeReplaced(HttpSessionBindingEvent event)
-	{
-		// Note that this method is called *after* the attribute has been replaced,
-		// and that event.getValue contains the old object.
-		if (event.getValue() instanceof ConversationManager)
-		{
-			ConversationManager oldConversationManager = (ConversationManager) event.getValue();
-			conversationWiperThread.removeConversationManager(oldConversationManager);
-		}
-
-		// The new object is already in the session and can be retrieved from there
-		HttpSession session = event.getSession();
-		String attrName = event.getName();
-		Object newObj = session.getAttribute(attrName);
-		if (newObj instanceof ConversationManager)
-		{
-			ConversationManager newConversationManager = (ConversationManager) newObj;
-			conversationWiperThread.addConversationManager(newConversationManager);
-		}
-	}
-
-	public void sessionDidActivate(HttpSessionEvent se)
-	{
-		// Reattach any ConversationManager objects in the session to the conversationWiperThread
-		HttpSession session = se.getSession();
-		Enumeration e = session.getAttributeNames();
-		while (e.hasMoreElements())
-		{
-			String attrName = (String) e.nextElement();
-			Object val = session.getAttribute(attrName);
-			if (val instanceof ConversationManager)
-			{
-				// TODO: maybe touch the "last accessed" stamp for the conversation manager
-				// and all its children? Without this, a conversation that has been passivated
-				// might almost immediately get cleaned up after being reactivated.
-				//
-				// Hmm..actually, we should make sure the wiper thread never cleans up anything
-				// associated with a session that is currently in use by a request. That should
-				// then be sufficient, as the timeouts will only apply after the end of the
-				// request that caused this activation to occur by which time any relevant
-				// timestamps have been restored.
-				ConversationManager cm = (ConversationManager) val;
-				conversationWiperThread.addConversationManager(cm);
-			}
-		}
-	}
-
-	public void sessionWillPassivate(HttpSessionEvent se)
-	{
-		// Detach all ConversationManager objects in the session from the conversationWiperThread.
-		// Without this, the ConversationManager and all its child objects would be kept in
-		// memory as well as being passivated to external storage. Of course this does mean
-		// that conversations in passivated sessions will not get timed out.
-		HttpSession session = se.getSession();
-		Enumeration e = session.getAttributeNames();
-		while (e.hasMoreElements())
-		{
-			String attrName = (String) e.nextElement();
-			Object val = session.getAttribute(attrName);
-			if (val instanceof ConversationManager)
-			{
-				ConversationManager cm = (ConversationManager) val;
-				conversationWiperThread.removeConversationManager(cm);
-			}
-		}
-	}
+    public void contextInitialized(ServletContextEvent event)
+    {
+        long checkTime = DEFAULT_CHECK_TIME;
+        String checkTimeString = event.getServletContext().getInitParameter(CHECK_TIME);
+        if (checkTimeString != null)
+        {
+            checkTime = Long.parseLong(checkTimeString);
+        }
+
+        conversationWiperThread = new ConversationWiperThread(checkTime);
+        conversationWiperThread.start();
+        log.debug("initialised");
+    }
+
+    public void contextDestroyed(ServletContextEvent event)
+    {
+        conversationWiperThread.interrupt();
+        conversationWiperThread = null;
+    }
+
+    public void attributeAdded(HttpSessionBindingEvent event)
+    {
+        // Somebody has called session.setAttribute
+        if (event.getValue() instanceof ConversationManager)
+        {
+            ConversationManager cm = (ConversationManager) event.getValue();
+            conversationWiperThread.addConversationManager(cm);
+        }
+    }
+
+    public void attributeRemoved(HttpSessionBindingEvent event)
+    {
+        // Either someone has called session.removeAttribute, or the session has been invalidated.
+        // When an HttpSession is invalidated (including when it "times out"), this method is
+        // called once for every attribute in the session; note however that at that time the
+        // session is invalid so in some containers certain methods (including getId and
+        // getAttribute) throw IllegalStateException.
+        if (event.getValue() instanceof ConversationManager)
+        {
+            ConversationManager cm = (ConversationManager) event.getValue();
+            conversationWiperThread.removeConversationManager(cm);
+        }
+    }
+
+    public void attributeReplaced(HttpSessionBindingEvent event)
+    {
+        // Note that this method is called *after* the attribute has been replaced,
+        // and that event.getValue contains the old object.
+        if (event.getValue() instanceof ConversationManager)
+        {
+            ConversationManager oldConversationManager = (ConversationManager) event.getValue();
+            conversationWiperThread.removeConversationManager(oldConversationManager);
+        }
+
+        // The new object is already in the session and can be retrieved from there
+        HttpSession session = event.getSession();
+        String attrName = event.getName();
+        Object newObj = session.getAttribute(attrName);
+        if (newObj instanceof ConversationManager)
+        {
+            ConversationManager newConversationManager = (ConversationManager) newObj;
+            conversationWiperThread.addConversationManager(newConversationManager);
+        }
+    }
+
+    public void sessionDidActivate(HttpSessionEvent se)
+    {
+        // Reattach any ConversationManager objects in the session to the conversationWiperThread
+        HttpSession session = se.getSession();
+        Enumeration e = session.getAttributeNames();
+        while (e.hasMoreElements())
+        {
+            String attrName = (String) e.nextElement();
+            Object val = session.getAttribute(attrName);
+            if (val instanceof ConversationManager)
+            {
+                // TODO: maybe touch the "last accessed" stamp for the conversation manager
+                // and all its children? Without this, a conversation that has been passivated
+                // might almost immediately get cleaned up after being reactivated.
+                //
+                // Hmm..actually, we should make sure the wiper thread never cleans up anything
+                // associated with a session that is currently in use by a request. That should
+                // then be sufficient, as the timeouts will only apply after the end of the
+                // request that caused this activation to occur by which time any relevant
+                // timestamps have been restored.
+                ConversationManager cm = (ConversationManager) val;
+                conversationWiperThread.addConversationManager(cm);
+            }
+        }
+    }
+
+    public void sessionWillPassivate(HttpSessionEvent se)
+    {
+        // Detach all ConversationManager objects in the session from the conversationWiperThread.
+        // Without this, the ConversationManager and all its child objects would be kept in
+        // memory as well as being passivated to external storage. Of course this does mean
+        // that conversations in passivated sessions will not get timed out.
+        HttpSession session = se.getSession();
+        Enumeration e = session.getAttributeNames();
+        while (e.hasMoreElements())
+        {
+            String attrName = (String) e.nextElement();
+            Object val = session.getAttribute(attrName);
+            if (val instanceof ConversationManager)
+            {
+                ConversationManager cm = (ConversationManager) val;
+                conversationWiperThread.removeConversationManager(cm);
+            }
+        }
+    }
 }