|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.myfaces.orchestra.conversation.ConversationUtils
public final class ConversationUtils
Some helpers usable for public use
Method Summary | |
---|---|
static java.lang.Object |
bindToCurrent(java.lang.Object instance)
Returns a proxy object that "binds" the specified instance to the current conversation. |
static void |
ensureConversationRedirect(java.lang.String conversationName,
java.lang.String redirectViewId)
If no conversation with name conversationName is active a redirect to
redirectViewId will be issued. |
static java.lang.Object |
getCurrentBean()
Return a reference to the most recently-invoked bean that is declared as being in a conversation scope. |
static java.lang.Object |
invalidateAndRestart(Conversation conversation)
End and restart the given conversation. |
static java.lang.Object |
invalidateAndRestartCurrent()
End and restart the current conversation. |
static void |
invalidateIfExists(java.lang.String name)
Invalidates a conversation if it exists. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.lang.Object invalidateAndRestart(Conversation conversation)
This method tries to return a bean whose name is the same as the name of the specified conversation. If no such bean is defined, then null is returned.
Note that the return value is quite different from the
Conversation.invalidateAndRestart()
method, which returns
an instance of the most recently invoked conversation-scoped bean.
public static java.lang.Object getCurrentBean()
When using an interceptor-based AOP framework, a bean that passes "this" to another object is bypassing any aspects. Any "callbacks" invoked via that reference will not apply the aspects that Orchestra has configured. This is particularly nasty when using Orchestra's persistence support as Orchestra uses an aspect to configure the correct "persistence context" for a bean when it is invoked.
Therefore, when a bean wishes to pass a reference to itself elsewhere then it should use this method rather than passing "this" directly. It is acknowledged that this is less than ideal as it does couple code to Orchestra.
In most cases it is better to call ConversationUtils.bindToCurrent(this)
.
That code works regardless of whether the caller is configured in the dependency-injection
framework as a conversation-scoped bean or not, ie it makes the code independent of the
configuration which is always a good idea.
public static java.lang.Object invalidateAndRestartCurrent()
The "current conversation" is the conversation associated with the most-recently-invoked conversation-scoped bean.
The returned object is a new instance of the most-recently-invoked conversation-scope bean.
This method is generally expected to be called from a conversation-scoped bean, in which case the conversation that is invalidated is the one in which the calling bean instance lives, and the returned object is the instance that will replace the calling object.
public static void ensureConversationRedirect(java.lang.String conversationName, java.lang.String redirectViewId)
conversationName
is active a redirect to
redirectViewId
will be issued.
If redirectViewId
starts with an slash ('/') the context path will be added.
public static void invalidateIfExists(java.lang.String name)
public static java.lang.Object bindToCurrent(java.lang.Object instance)
Invoking the returned proxy object will set up the current conversation before passing the method call on to the provided instance, ie calls to the instance then run in the same conversation as the code making a call to this method.
This is simply a shorcut for "Conversation.getCurrentInstance().bind(instance);".
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |