Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.myfaces.orchestra.conversation
Class ConversationManager

    java.lang.Object
      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.

There is expected to be one instance of this class per http-session, managing all of the data associated with all browser windows that use that http-session.

One particular task of this class is to return "the current" ConversationContext object for the current http request (from the set of ConversationContext objects that this manager object holds). The request url is presumed to include a query-parameter that specifies the id of the appropriate ConversationContext object to be used. If no such query-parameter is present, then a new ConversationContext object will automatically be created.

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

Constructor Summary
`protected` | `ConversationManager()`

Method Summary
`void` | `activateConversationContext(ConversationContext ctx)` Make the specific context the current context for the current HTTP session.
`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.
`ConversationContext` | `createConversationContext(ConversationContext parent)` This will create a new conversation context using the specified context as its parent.
`Conversation` | `getConversation(java.lang.String name)` Get the conversation with the given name
`ConversationContext` | `getConversationContext(java.lang.Long conversationContextId)` Get the conversation context for the given id.
`java.lang.Long` | `getConversationContextId()` Deprecated. This method should not be needed by external classes, and was inconsistent with other methods on this class.
`ConversationContext` | `getCurrentConversationContext()` Get the current conversation context.
`ConversationContext` | `getCurrentRootConversationContext()` Get the current root conversation context (aka the window conversation context).
`static ConversationManager` | `getInstance()` Get the conversation manager for the current http session.
`static ConversationManager` | `getInstance(boolean create)` Get the conversation manager for the current http session.
`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()` Return true if there is a conversation context associated with the current request.
`java.util.Iterator` | `iterateConversations()` Returns an iterator over all the Conversation objects in the current conversation context.
`void` | `removeAndInvalidateAllConversationContexts()`
`void` | `removeAndInvalidateConversationContext(ConversationContext context)` Removes the specified contextId from the set of known contexts, and deletes every conversation in it.
`protected void` | `removeConversation(java.lang.String name)` Remove a conversation Note: It is assumed that the conversation has already been invalidated
`protected void` | `removeConversationContext(java.lang.Long conversationContextId)` Deprecated. This method is not actually used by anything.
`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`

Constructor Detail

### ConversationManager

    protected ConversationManager()

Method Detail

### getInstance

    public static ConversationManager getInstance()

  Get the conversation manager for the current http session.

  If none exists, then a new instance is allocated and stored in the current http session. Null is never returned.

  Throws IllegalStateException if the Orchestra FrameworkAdapter has not been correctly configured.

### getInstance

    public static ConversationManager getInstance(boolean create)

  Get the conversation manager for the current http session.

  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()

  Deprecated. This method should not be needed by external classes, and was inconsistent with other methods on this class.

  Get the current, or create a new unique conversationContextId.

  This method is deprecated because, unlike all the other get methods, it actually creates the value if it does not exist. Other get methods (except getInstance) return null if the data does not exist. In addition, this method is not really useful to external code and probably should never have been exposed as a public API in the first place; external code should never need to force the creation of a ConversationContext.

  For internal use within this class, use either findConversationContextId() or getOrCreateConversationContextId().

  To just obtain the current ConversationContext if it exists, see method getCurrentConversationContext().

### getConversationContext

    public ConversationContext getConversationContext(java.lang.Long conversationContextId)

  Get the conversation context for the given id.

  Null is returned if there is no ConversationContext with the specified id.

  Param conversationContextId must not be null.

  Public since version 1.3.

### getOrCreateConversationContext

    protected ConversationContext getOrCreateConversationContext(java.lang.Long conversationContextId)

  Get the conversation context for the given id.

  If there is no such conversation context a new one will be created. The new conversation context will be a "top-level" context (ie has no parent).

  The new conversation context will not be the current conversation context, unless the id passed in was already configured as the current conversation context id.

### createConversationContext

    public ConversationContext createConversationContext(ConversationContext parent)

  This will create a new conversation context using the specified context as its parent.

  The returned context is not selected as the "current" one; see activateConversationContext.

  Since:
    1.3

### activateConversationContext

    public void activateConversationContext(ConversationContext ctx)

  Make the specific context the current context for the current HTTP session.

  Methods like getCurrentConversationContext will then return the specified context object.

  Since:
    1.2

### clearCurrentConversationContext

    public void clearCurrentConversationContext()

  Ends all conversations within the current context; the context itself will remain active.

### removeAndInvalidateConversationContext

    public void removeAndInvalidateConversationContext(ConversationContext context)

  Removes the specified contextId from the set of known contexts, and deletes every conversation in it.

  Objects in the conversation which implement ConversationAware will have callbacks invoked.

  The conversation being removed must not be the currently active context. If it is, then method activateConversationContext should first be called on some other instance (perhaps the parent of the one being removed) before this method is called.

  Since:
    1.3

### removeConversationContext

    protected void removeConversationContext(java.lang.Long conversationContextId)

  Deprecated. This method is not actually used by anything.

  Removes the specified contextId from the set of known contexts.

  It does nothing else. Maybe it should be called "detachConversationContext" or similar.

### 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 Note: It is 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.

  In a simple Orchestra application this will always be a root conversation context. When using a dialog/page-flow environment the context that is returned might have a parent context.

  Null is returned if there is no current conversationContext.

### hasConversationContext

    public boolean hasConversationContext()

  Return true if there is a conversation context associated with the current request.

### getCurrentRootConversationContext

    public ConversationContext getCurrentRootConversationContext()

  Get the current root conversation context (aka the window conversation context).

  Null is returned if it does not exist.

  Since:
    1.2

### 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.

### removeAndInvalidateAllConversationContexts

    public void removeAndInvalidateAllConversationContexts()

  Since:
    1.4

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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