org.apache.myfaces.orchestra.conversation.spring
Class SpringConversationScope

java.lang.Object
  extended by org.apache.myfaces.orchestra.conversation.spring.AbstractSpringOrchestraScope
      extended by org.apache.myfaces.orchestra.conversation.spring.SpringConversationScope
All Implemented Interfaces:
ConversationFactory, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.config.Scope, org.springframework.context.ApplicationContextAware

public class SpringConversationScope
extends AbstractSpringOrchestraScope

Handles creation and lookup of any bean whose bean-definition specifies a scope that maps to an instance of this type.

A scope bean handles Spring-specific callbacks in order to locate or create any beans whose definition specifies that scope. A scope can also be thought of as a "conversation template", as this object is responsible for creating a conversation when one is needed but does not yet exist.

Example

A sample configuration for a conversation scope with persistence:
 <bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
   <property name="scopes">
     <map>
       <entry key="conversation.manual">
         <bean class="org.apache.myfaces.orchestra.conversation.spring.SpringConversationScope">
           <property name="advices">
             <list>
               <ref bean="persistentContextConversationInterceptor" />
             </list>
           </property>
         </bean>
       </entry>
     </map>
   </property>
 </bean>
 
 
 <bean id="persistentContextConversationInterceptor"
    class="org.apache.myfaces.orchestra.conversation.spring.PersistenceContextConversationInterceptor">
   <property name="persistenceContextFactory" ref="yourPersistentContextFactory" />
 </bean>
 

Conversation properties

The following properties can be defined on a scope and then apply to any conversation that is created to hold a bean of this scope:

Other Notes

If the bean definition does not specify a conversation name, then the bean name is used as the conversation name.

As shown above, a list of AOP Advices can be specified for the scope, in which case each of the advices gets configured for any bean declared with this scope.


Field Summary
static String LIFETIME_ACCESS
           
static String LIFETIME_FLASH
          Deprecated. Use LIFETIME_ACCESS instead.
static String LIFETIME_MANUAL
           
 
Constructor Summary
SpringConversationScope()
           
 
Method Summary
 Conversation createConversation(ConversationContext context, String name)
          Implementation of ConversationFactory interface.
 String getLifetime()
          See setLifetime(java.lang.String).
 Integer getTimeout()
          See setTimeout(java.lang.Integer).
protected  void initAspects(Conversation conversation)
          Add aspects to a newly-created conversation.
protected  void notifyAccessConversation(Conversation conversation)
          Mark the specified conversation as having been accessed.
 void setLifetime(String lifetime)
          Must be one of "manual" or "access".
 void setTimeout(Integer timeout)
          The timeout in minutes when the conversation will end.
 
Methods inherited from class org.apache.myfaces.orchestra.conversation.spring.AbstractSpringOrchestraScope
assertSameScope, buildBeanName, defineBeanPostProcessors, get, getAdvices, getApplicationContext, getConversationForBean, getConversationId, getConversationNameForBean, getExplicitConversationName, getProxy, getRealBean, registerDestructionCallback, remove, setAdvices, setApplicationContext, setAutoProxy, setBeanFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LIFETIME_FLASH

public static final String LIFETIME_FLASH
Deprecated. Use LIFETIME_ACCESS instead.
See Also:
Constant Field Values

LIFETIME_ACCESS

public static final String LIFETIME_ACCESS
See Also:
Constant Field Values

LIFETIME_MANUAL

public static final String LIFETIME_MANUAL
See Also:
Constant Field Values
Constructor Detail

SpringConversationScope

public SpringConversationScope()
Method Detail

getTimeout

public Integer getTimeout()
See setTimeout(java.lang.Integer).


setTimeout

public void setTimeout(Integer timeout)
The timeout in minutes when the conversation will end. See ConversationTimeoutableAspect.timeout for the default timeout.


getLifetime

public String getLifetime()
See setLifetime(java.lang.String).


setLifetime

public void setLifetime(String lifetime)
Must be one of "manual" or "access".

Defaults to "manual".

Note that "flash" is also supported as an alias for "access", for reasons of backwards compatibility with release 1.0.


createConversation

public Conversation createConversation(ConversationContext context,
                                       String name)
Implementation of ConversationFactory interface.


initAspects

protected void initAspects(Conversation conversation)
Add aspects to a newly-created conversation.

Subclasses are expected to call super.initAspects, then make zero or more calls to conversation.addAspect.


notifyAccessConversation

protected void notifyAccessConversation(Conversation conversation)
Mark the specified conversation as having been accessed.

This affects conversation timeouts, and the removal of access-scoped conversations.

Overrides:
notifyAccessConversation in class AbstractSpringOrchestraScope


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