org.apache.myfaces.orchestra.conversation
Class ConversationManager

java.lang.Object
  extended by org.apache.myfaces.orchestra.conversation.ConversationManager
All Implemented Interfaces:
java.io.Serializable

public class ConversationManager
extends java.lang.Object
implements java.io.Serializable

Deals with the various conversation contexts in the current session.

A new conversation context will be created if the servlet request did not specify an existing conversation context id.

At the current time, this object does not serialize well. Any attempt to serialize this object (including any serialization of the user session) will just cause it to be discarded.

TODO: fix serialization issues.

See Also:
Serialized Form

Field Summary
(package private) static java.lang.String CONVERSATION_CONTEXT_PARAM
           
 
Constructor Summary
protected ConversationManager()
           
 
Method Summary
protected  void checkTimeouts()
          Check the timeout for each conversation context, and all conversations within those contexts.
 void clearCurrentConversationContext()
          Ends all conversations within the current context; the context itself will remain active.
 Conversation getConversation(java.lang.String name)
          Get the conversation with the given name
protected  ConversationContext getConversationContext(java.lang.Long conversationContextId)
          Get the conversation context for the given id
 java.lang.Long getConversationContextId()
          Get the current, or create a new unique conversationContextId.
 ConversationContext getCurrentConversationContext()
          Get the current conversation context.
static ConversationManager getInstance()
          Get the conversation manager.
static ConversationManager getInstance(boolean create)
          Get the conversation manager.
 ConversationMessager getMessager()
          Get the Messager used to inform the user about anomalies.
protected  ConversationContext getOrCreateConversationContext(java.lang.Long conversationContextId)
          Get the conversation context for the given id.
 boolean hasConversation(java.lang.String name)
          check if the given conversation is active
 boolean hasConversationContext()
          check if we have a conversation context
 java.util.Iterator iterateConversations()
          Returns an iterator over all the Conversation objects in the current conversation context.
protected  void removeConversation(java.lang.String name)
          Remove a conversation Notice: Its assumed that the conversation has already been invalidated
protected  void removeConversationContext(java.lang.Long conversationContextId)
          Destroy the given conversation context

Notice: its assumed that the context is already been destroyed

 Conversation startConversation(java.lang.String name, ConversationFactory factory)
          Start a conversation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONVERSATION_CONTEXT_PARAM

static final java.lang.String CONVERSATION_CONTEXT_PARAM
See Also:
Constant Field Values
Constructor Detail

ConversationManager

protected ConversationManager()
Method Detail

getInstance

public static ConversationManager getInstance()
Get the conversation manager. This creates a new one if none exists.


getInstance

public static ConversationManager getInstance(boolean create)
Get the conversation manager.

When create is true, an instance is always returned; one is created if none currently exists for the current user session.

When create is false, null is returned if no instance yet exists for the current user session.


getConversationContextId

public java.lang.Long getConversationContextId()
Get the current, or create a new unique conversationContextId.

The current conversationContextId will retrieved from the request parameters. If no such parameter is present then a new id will be allocated and a new ConversationContext created.

In either case the result will be stored within the request for faster lookup.

Note that there is no security flaw regarding injection of fake context ids; the id must match one already in the session and there is no security problem with two windows in the same session exchanging ids.


getConversationContext

protected ConversationContext getConversationContext(java.lang.Long conversationContextId)
Get the conversation context for the given id


getOrCreateConversationContext

protected ConversationContext getOrCreateConversationContext(java.lang.Long conversationContextId)
Get the conversation context for the given id.
If there is no conversation context a new one will be created


clearCurrentConversationContext

public void clearCurrentConversationContext()
Ends all conversations within the current context; the context itself will remain active.


removeConversationContext

protected void removeConversationContext(java.lang.Long conversationContextId)

Destroy the given conversation context

Notice: its assumed that the context is already been destroyed


startConversation

public Conversation startConversation(java.lang.String name,
                                      ConversationFactory factory)
Start a conversation.

See Also:
ConversationContext.startConversation(String, ConversationFactory)

removeConversation

protected void removeConversation(java.lang.String name)
Remove a conversation

Notice: Its assumed that the conversation has already been invalidated

See Also:
ConversationContext.removeConversation(String)

getConversation

public Conversation getConversation(java.lang.String name)
Get the conversation with the given name

Returns:
null if no conversation context is active or if the conversation did not exist.

hasConversation

public boolean hasConversation(java.lang.String name)
check if the given conversation is active


iterateConversations

public java.util.Iterator iterateConversations()
Returns an iterator over all the Conversation objects in the current conversation context. Never returns null, even if no conversation context exists.


getCurrentConversationContext

public ConversationContext getCurrentConversationContext()
Get the current conversation context.

Returns:
null if there is no context active

hasConversationContext

public boolean hasConversationContext()
check if we have a conversation context


getMessager

public ConversationMessager getMessager()
Get the Messager used to inform the user about anomalies.

What instance is returned is controlled by the FrameworkAdapter. See FrameworkAdapter for details.


checkTimeouts

protected void checkTimeouts()
Check the timeout for each conversation context, and all conversations within those contexts.

If any conversation has not been accessed within its timeout period then clear the context.

Invoke the checkTimeout method on each context so that any conversation that has not been accessed within its timeout is invalidated.



Copyright 2007 The Apache Software Foundation. All Rights Reserved.