org.apache.myfaces.extensions.cdi.jpa.impl.transaction
Class TransactionalInterceptorStrategy

java.lang.Object
  extended by org.apache.myfaces.extensions.cdi.jpa.impl.transaction.TransactionalInterceptorStrategy
All Implemented Interfaces:
Serializable, InterceptorStrategy, PersistenceStrategy

@Dependent
public class TransactionalInterceptorStrategy
extends Object
implements PersistenceStrategy

Default implementation of our pluggable PersistenceStrategy. It supports nested Transactions with the MANDATORY behaviour.

The outermost @Transactional interceptor for the given Qualifier will open an EntityTransaction and the outermost @Transactional interceptor for all EntityManagers will flush and subsequently close all open transactions.

If an Exception occurs in flushing the EntityManagers or any other Exception gets thrown inside the intercepted method chain and not gets catched until the outermost @Transactional interceptor gets reached, then all open transactions will get rollbacked.

If you like to implement your own PersistenceStrategy, then use the standard CDI @Alternative mechanism.

See Also:
Serialized Form

Constructor Summary
TransactionalInterceptorStrategy()
           
 
Method Summary
 Object execute(javax.interceptor.InvocationContext invocationContext)
           
protected  Transactional extractTransactionalAnnotation(javax.interceptor.InvocationContext context)
           
protected  Class<? extends Annotation> getTransactionQualifier(Transactional transactionalAnnotation)
           
protected  Exception prepareException(Exception e)
          This method might get overridden in subclasses to supply better error messages.
protected  javax.enterprise.inject.spi.Bean<javax.persistence.EntityManager> resolveEntityManagerBean(Class<? extends Annotation> qualifierClass)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionalInterceptorStrategy

public TransactionalInterceptorStrategy()
Method Detail

execute

public Object execute(javax.interceptor.InvocationContext invocationContext)
               throws Exception
Specified by:
execute in interface InterceptorStrategy
Throws:
Exception

prepareException

protected Exception prepareException(Exception e)
This method might get overridden in subclasses to supply better error messages. This is useful if e.g. a JPA provider only provides a stubborn Exception for their ConstraintValidationExceptions.

Parameters:
e -
Returns:

extractTransactionalAnnotation

protected Transactional extractTransactionalAnnotation(javax.interceptor.InvocationContext context)

getTransactionQualifier

protected Class<? extends Annotation> getTransactionQualifier(Transactional transactionalAnnotation)

resolveEntityManagerBean

protected javax.enterprise.inject.spi.Bean<javax.persistence.EntityManager> resolveEntityManagerBean(Class<? extends Annotation> qualifierClass)


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