org.apache.myfaces.orchestra.conversation
Class ConversationContext

java.lang.Object
  extended by org.apache.myfaces.orchestra.conversation.ConversationContext

public class ConversationContext
extends java.lang.Object

A ConversationContext is a container for a set of conversations.

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.

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.


Constructor Summary
protected ConversationContext(long id)
           
 
Method Summary
protected  void checkConversationTimeout()
          Check the timeout for every conversation in this context.
protected  void clear()
          Invalidate all conversations within this context.
 java.lang.Object getAttribute(java.lang.String name)
          Get a specific attribute.
protected  Conversation getConversation(java.lang.String name)
          Get a conversation by name.
 long getId()
          The conversation context id, unique within the current http session.
 long getLastAccess()
          The system time in millis when this conversation has been accessed last.
 long getTimeout()
          Get the timeout after which this context will be closed.
 boolean hasAttribute(java.lang.String name)
          Check if this conversationContext holds a specific attribute.
protected  boolean hasConversation(java.lang.String name)
          Check if the given conversation exists.
protected  boolean hasConversations()
          See if there is a conversation with the specified name.
 java.util.Iterator iterateConversations()
          Iterates over all the conversations in this context.
 java.lang.Object removeAttribute(java.lang.String name)
          Remove an attribute from the conversationContext.
protected  void removeConversation(Conversation conversation)
          Remove the conversation from this context.
protected  void removeConversation(java.lang.String name)
          Remove the conversation with the given name from this context.
 void setAttribute(java.lang.String name, java.lang.Object attribute)
          Add an attribute to the conversationContext.
 void setTimeout(long timeoutMillis)
          Set the timeout after which this context will be closed.
protected  Conversation startConversation(java.lang.String name, ConversationFactory factory)
          Start a conversation if not already started.
protected  void touch()
          Mark this context as having been used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConversationContext

protected ConversationContext(long id)
Method Detail

getId

public long getId()
The conversation context id, unique within the current http session.


touch

protected void touch()
Mark this context as having been used.


getLastAccess

public long getLastAccess()
The system time in millis when this conversation has been accessed last.


getTimeout

public long getTimeout()
Get the timeout after which this context will be closed.

See Also:
setTimeout(long)

setTimeout

public void setTimeout(long timeoutMillis)
Set the timeout after which this context will be closed.

A value of -1 means no timeout checking.


clear

protected void clear()
Invalidate all conversations within this context.


startConversation

protected Conversation startConversation(java.lang.String name,
                                         ConversationFactory factory)
Start a conversation if not already started.


removeConversation

protected void removeConversation(Conversation conversation)
Remove the conversation from this context.

Notice: It is assumed that the conversation has already been invalidated.


removeConversation

protected void removeConversation(java.lang.String name)
Remove the conversation with the given name from this context.

Notice: Its assumed that the conversation has already been invalidated


hasConversations

protected boolean hasConversations()
See if there is a conversation with the specified name.


hasConversation

protected boolean hasConversation(java.lang.String name)
Check if the given conversation exists.


getConversation

protected Conversation getConversation(java.lang.String name)
Get a conversation by name.


iterateConversations

public java.util.Iterator iterateConversations()
Iterates over all the conversations in this context.

Returns:
An iterator over a copy of the conversation list. It is safe to remove objects from the conversation list while iterating, as the iterator refers to a different collection.

checkConversationTimeout

protected void checkConversationTimeout()
Check the timeout for every conversation in this context.

This method does not check the timeout for this context object itself.


setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object attribute)
Add an attribute to the conversationContext.

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.


hasAttribute

public boolean hasAttribute(java.lang.String name)
Check if this conversationContext holds a specific attribute.


getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Get a specific attribute.


removeAttribute

public java.lang.Object removeAttribute(java.lang.String name)
Remove an attribute from the conversationContext.



Copyright 2007 The Apache Software Foundation. All Rights Reserved.