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

java.lang.Object
  extended by org.apache.myfaces.orchestra.conversation.spring.PersistenceContextConversationInterceptor
All Implemented Interfaces:
org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor

public class PersistenceContextConversationInterceptor
extends Object
implements org.aopalliance.intercept.MethodInterceptor

Maintain the appropriate persistence state for the current call-stack.

This class is a MethodInterceptor (an AOP Advice) which should be configured to intercept calls to all conversation-scoped beans. It ensures that the appropriate PersistenceContext object for this conversation is placed into the default location, by invoking the bind method on the persistence context object. Typically the bind method stores the persistence context into a thread-local variable, but that is implementation-specific.

When Spring code retrieves the persistence context in order to inject it into a bean, it then finds the correct context for the conversation that is associated with the nearest conversation-scoped bean in the callstack.

If no PersistenceContext yet exists for the conversation associated with the bean that is being invoked then one is created using PersistenceContextFactory.

A reference to the PersistenceContext is put into the conversation attribute map wrapped in an PersistenceContextCloser so that when the conversation ends a callback occurs on it which closes the underlying object.


Field Summary
static String REQUEST_ATTRIBUTE
           
 
Constructor Summary
PersistenceContextConversationInterceptor()
           
 
Method Summary
 Object invoke(org.aopalliance.intercept.MethodInvocation methodInvocation)
           
 void setPersistenceContextFactory(PersistenceContextFactory persistenceContextFactory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REQUEST_ATTRIBUTE

public static final String REQUEST_ATTRIBUTE
Constructor Detail

PersistenceContextConversationInterceptor

public PersistenceContextConversationInterceptor()
Method Detail

setPersistenceContextFactory

public void setPersistenceContextFactory(PersistenceContextFactory persistenceContextFactory)

invoke

public Object invoke(org.aopalliance.intercept.MethodInvocation methodInvocation)
              throws Throwable
Specified by:
invoke in interface org.aopalliance.intercept.MethodInterceptor
Throws:
Throwable


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