org.objectweb.easybeans.persistence.interceptors
Class NoTxMethodCallOnlyEntityManagerInterceptor

java.lang.Object
  extended by org.objectweb.easybeans.persistence.interceptors.NoTxMethodCallOnlyEntityManagerInterceptor
All Implemented Interfaces:
EasyBeansInterceptor

public class NoTxMethodCallOnlyEntityManagerInterceptor
extends java.lang.Object
implements EasyBeansInterceptor

This interceptor is used for the Transaction-scoped persistence context when there is no transaction. In this case the persistence context is used only for the method call. Interceptor adds in the thread local a new EntityManager that is closed at the end of the method.

Author:
Florent Benoit

Constructor Summary
NoTxMethodCallOnlyEntityManagerInterceptor()
           
 
Method Summary
 java.lang.Object intercept(EasyBeansInvocationContext invocationContext)
          Creates a new EntityManager before the method and close it at the end.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NoTxMethodCallOnlyEntityManagerInterceptor

public NoTxMethodCallOnlyEntityManagerInterceptor()
Method Detail

intercept

public java.lang.Object intercept(EasyBeansInvocationContext invocationContext)
                           throws java.lang.Exception
Creates a new EntityManager before the method and close it at the end.

Specified by:
intercept in interface EasyBeansInterceptor
Parameters:
invocationContext - context with useful attributes on the current invocation
Returns:
result of the next invocation (to chain interceptors)
Throws:
java.lang.Exception - if interceptor fails