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 ConversationUtils

    java.lang.Object
      org.apache.myfaces.orchestra.conversation.ConversationUtils

    public final class ConversationUtils

extends java.lang.Object

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

### invalidateAndRestart

    public static java.lang.Object invalidateAndRestart(Conversation conversation)

  End and restart the given 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.

### getCurrentBean

    public static java.lang.Object getCurrentBean()

  Return a reference to the most recently-invoked bean that is declared as being in a conversation scope.

  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.

  Since:
    1.1

### invalidateAndRestartCurrent

    public static java.lang.Object invalidateAndRestartCurrent()

  End and restart the current conversation.

  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.

### ensureConversationRedirect

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

  If `redirectViewId` starts with an slash ('/') the context path will be added.

### invalidateIfExists

    public static void invalidateIfExists(java.lang.String name)

  Invalidates a conversation if it exists.

### bindToCurrent

    public static java.lang.Object bindToCurrent(java.lang.Object instance)

  Returns a proxy object that "binds" the specified instance to the current conversation.

  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);".

  Since:
    1.3

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.