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 2007/10/04 22:54:26 UTC

svn commit: r582007 - /myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationContext.java

Author: skitching
Date: Thu Oct  4 13:54:26 2007
New Revision: 582007

URL: http://svn.apache.org/viewvc?rev=582007&view=rev
Log:
Add comments. Remove unnecessary log statement. Rename variable for clarity. All pretty trivial.

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

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationContext.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationContext.java?rev=582007&r1=582006&r2=582007&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationContext.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationContext.java Thu Oct  4 13:54:26 2007
@@ -28,24 +28,35 @@
 import java.util.TreeMap;
 
 /**
- * <p>The ConversationContext handles all conversations within the current context</p>
- * <p/>
- * Like the conversation this context has a timeout too which will end this context
- * if not accessed within the given timeout.
- * </p>
+ * A ConversationContext is a container for a set of conversations.
+ * <p>
+ * Normally there is only one ConversationContext per http session. However there can
+ * be multiple instances if the user has multiple concurrent windows open into the same
+ * webapp, using the ox:separateConversationContext or other similar mechanism.
+ * <p>
+ * Like the conversation class, a context can also have a timeout which will cause it
+ * to be ended automatically if not accessed within the given period.
  */
 public class ConversationContext
 {
 	private final Log log = LogFactory.getLog(ConversationContext.class);
 
+	// This id is attached as a query parameter to every url rendered in a page
+	// (forms and links) so that if that url is invoked then the request will
+	// cause the same context to be used from the user's http session. 
 	private final long id;
 
+	// See addAttribute
 	private final Map attributes = new TreeMap();
 
+	// The conversations held by this context, keyed by conversation name.
 	private final Map conversations = new TreeMap();
 
+	// time at which this was last accessed, used for timeouts.
 	private long lastAccess;
-	private long timeout = 30 * 60 * 1000;
+
+	// default timeout for contexts: 30 minutes.
+	private long timeoutMillis = 30 * 60 * 1000;
 
 	protected ConversationContext(long id)
 	{
@@ -55,13 +66,16 @@
 	}
 
 	/**
-	 * the conversation context id
+	 * The conversation context id, unique within the current http session.
 	 */
 	public long getId()
 	{
 		return id;
 	}
 
+	/**
+	 * Mark this context as having been used.
+	 */
 	protected void touch()
 	{
 		lastAccess = System.currentTimeMillis();
@@ -82,21 +96,21 @@
 	 */
 	public long getTimeout()
 	{
-		return timeout;
+		return timeoutMillis;
 	}
 
 	/**
 	 * Set the timeout after which this context will be closed.
-	 * <br />
+	 * <p>
 	 * A value of -1 means no timeout checking.
 	 */
-	public void setTimeout(long timeout)
+	public void setTimeout(long timeoutMillis)
 	{
-		this.timeout = timeout;
+		this.timeoutMillis = timeoutMillis;
 	}
 
 	/**
-	 * <p>Invalidate all conversations within this context</p>
+	 * Invalidate all conversations within this context.
 	 */
 	protected void clear()
 	{
@@ -135,8 +149,9 @@
 	}
 
 	/**
-	 * <p>remove the conversation from this context.</p>
-	 * <p>Notice: Its assumed that the conversation has already been invalidated</p>
+	 * Remove the conversation from this context.
+	 * 
+	 * <p>Notice: It is assumed that the conversation has already been invalidated.</p>
 	 */
 	protected void removeConversation(Conversation conversation)
 	{
@@ -148,7 +163,8 @@
 	}
 
 	/**
-	 * <p>remove the conversation with the given name from this context.</p>
+	 * Remove the conversation with the given name from this context.
+	 * 
 	 * <p>Notice: Its assumed that the conversation has already been invalidated</p>
 	 */
 	protected void removeConversation(String name)
@@ -165,7 +181,7 @@
 	}
 
 	/**
-	 * see if there is a conversation
+	 * See if there is a conversation with the specified name.
 	 */
 	protected boolean hasConversations()
 	{
@@ -177,7 +193,7 @@
 	}
 
 	/**
-	 * check if the given conversation exists
+	 * Check if the given conversation exists.
 	 */
 	protected boolean hasConversation(String name)
 	{
@@ -189,7 +205,7 @@
 	}
 
 	/**
-	 * get a conversation by name
+	 * Get a conversation by name.
 	 */
 	protected Conversation getConversation(String name)
 	{
@@ -225,7 +241,7 @@
 	}
 
 	/**
-	 * check the context and conversation timeouts
+	 * Check the context and conversation timeouts.
 	 */
 	protected void checkConversationTimeout()
 	{
@@ -256,25 +272,22 @@
 	}
 
 	/**
-	 * add an attribute to the conversationContext
+	 * Add an attribute to the conversationContext.
+	 * <p>
+	 * A context provides a map into which any arbitrary objects can be stored. It
+	 * isn't a major feature of the context, but can occasionally be useful.
 	 */
 	public void setAttribute(String name, Object attribute)
 	{
 		synchronized(this)
 		{
 			removeAttribute(name);
-
-			if (log.isDebugEnabled())
-			{
-				log.debug("put bean to conversationContext:" + name + "(attribute=" + attribute + ")");
-			}
-
 			attributes.put(name, attribute);
 		}
 	}
 
 	/**
-	 * check if this conversationContext holds a specific attribute
+	 * Check if this conversationContext holds a specific attribute.
 	 */
 	public boolean hasAttribute(String name)
 	{
@@ -285,7 +298,7 @@
 	}
 
 	/**
-	 * get a specific attribute
+	 * Get a specific attribute.
 	 */
 	public Object getAttribute(String name)
 	{
@@ -296,7 +309,7 @@
 	}
 
 	/**
-	 * <p>remove an attribute from the conversationContext.</p>
+	 * Remove an attribute from the conversationContext.
 	 */
 	public Object removeAttribute(String name)
 	{