|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.myfaces.orchestra.conversation.Conversation
public class Conversation
A Conversation is a container for a set of beans.
Optionally, a PersistenceContext can also be associated with a conversation.
There are various ways how to get access to a Conversation instance:
getCurrentInstance()
if you are calling from a
conversation-scoped bean, or something that is called from such a bean.ConversationManager.getConversation(String)
ConversationAware
or ConversationBindingListener
interface in a bean.Conversation instances are typically created when an EL expression references a bean whose definition indicates that it is in a conversation scope.
A conversation instance is typically destroyed:
Constructor Summary | |
---|---|
Conversation(ConversationContext conversationContext,
java.lang.String name,
ConversationFactory factory)
|
Method Summary | |
---|---|
void |
addAspect(ConversationAspect aspect)
Add an Aspect to this conversation. |
protected void |
checkValid()
Assert the conversation is valid. |
protected void |
destroy()
Destroy the conversation. |
ConversationAspect |
getAspect(java.lang.Class conversationAspectClass)
Get the aspect corresponding to the given class. |
java.lang.Object |
getAttribute(java.lang.String name)
Get a specific attribute, ie a named managed bean. |
protected java.util.Map |
getBeans()
Get direct access to the beans map. |
static Conversation |
getCurrentInstance()
Get the current conversation. |
ConversationFactory |
getFactory()
Return the factory that created this conversation. |
long |
getLastAccess()
The system time in millis when this conversation has been accessed last |
java.lang.String |
getName()
Return the name of this conversation. |
boolean |
hasAttribute(java.lang.String name)
Check if this conversation holds a specific attribute (ie has a specific named managed bean instance). |
void |
invalidate()
Invalidate (end) the conversation. |
Conversation |
invalidateAndRestart()
Invalidate/End and restart the conversation. |
boolean |
isInvalid()
Return true if the conversation is invalid, ie should not be used. |
java.lang.Object |
removeAttribute(java.lang.String name)
Remove a bean from the conversation. |
void |
setAttribute(java.lang.String name,
java.lang.Object bean)
Add the given bean to the conversation scope. |
protected void |
setBeans(java.util.Map beans)
Replace the current beans map. |
protected void |
touch()
Mark this conversation as having been used at the current time. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Conversation(ConversationContext conversationContext, java.lang.String name, ConversationFactory factory)
Method Detail |
---|
protected void touch()
Conversations can have "timeouts" associated with them, so that when a user stops a conversation and goes off to work on some other part of the webapp then the conversation's memory can eventually be reclaimed.
Whenever user code causes this conversation object to be looked up and returned, this "touch" method is invoked to indicate that the conversation is in use. Direct conversation lookups by user code can occur, but the most common access is expected to be via an EL expression which a lookup of a bean that is declared as being in conversation scope. The bean lookup causes the corresponding conversation to be looked up, which triggers this method.
public long getLastAccess()
public void setAttribute(java.lang.String name, java.lang.Object bean)
This will fire a ConversationBindingEvent
on the bean parameter
object if the bean implements the ConversationBindingListener
interface
Note that any object can be stored into the conversation; it is not limited to managed beans declared in a configuration file. This feature is not expected to be heavily used however; most attributes of a conversation are expected to be externally-declared "managed beans".
protected void checkValid()
public java.lang.String getName()
A conversation name is unique within a conversation context.
public ConversationFactory getFactory()
Note that this factory will have set the initial aspects of this factory, which configure such things as the lifetime (access, manual, etc) and conversation timeout properties.
public void invalidate()
If the conversation is currently active (ie the current call stack contains an object that belongs to this conversation) then the conversation will just queue the object for later destruction. Calls to methods like ConversationManager.getConversation(...) may still return this object, and it will continue to function as a normal instance.
Only when the conversation is no longer active will the conversation (and the beans it contains) actually be marked as invalid ("destroyed"). Once the conversation has been destroyed, the ConversationManager will discard all references to it, meaning it will no longer be accessable via lookups like ConversationManager.getConversation(). If something does still have a reference to a destroyed conversation, then invoking almost any method on that object will throw an IllegalStateException. In particular, adding a bean to the conversation (invoking addAttribute) is not allowed.
public Conversation invalidateAndRestart()
This conversation object is immediately "destroyed" (see comments for method invalidate), and a new instance is registered with the conversation manager using the same name. The new instance is returned from this method.
Any code holding a reference to the old conversation instance will receive an IllegalStateException when calling almost any method on that instance.
public boolean isInvalid()
protected void destroy()
ConversationBindingListener
about the conversation end
public boolean hasAttribute(java.lang.String name)
public java.lang.Object getAttribute(java.lang.String name)
public java.lang.Object removeAttribute(java.lang.String name)
This will fire a ConversationBindingEvent
if the bean implements the
ConversationBindingListener
interface.
public static Conversation getCurrentInstance()
public ConversationAspect getAspect(java.lang.Class conversationAspectClass)
public void addAspect(ConversationAspect aspect)
protected java.util.Map getBeans()
This method is only intended for use by subclasses that manipulate the beans map in unusual ways. In general, it is better to use the setAttribute/removeAttribute methods rather than accessing beans via this map. Adding/removing entries in this map will not trigger the usual callbacks on the bean objects themselves.
protected void setBeans(java.util.Map beans)
getBeans()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |