@Dependent @Alternative public class BeanManagedUserTransactionStrategy extends ResourceLocalTransactionStrategy
TransactionStrategy for using JTA (bean-managed-)transactions
(including XA transactions with a XA DataSource).
The basic features are identical to the ResourceLocalTransactionStrategy (for
persistent-unit-transaction-type 'RESOURCE_LOCAL' only).
| Modifier and Type | Field and Description |
|---|---|
protected static String |
USER_TRANSACTION_JNDI_NAME |
| Constructor and Description |
|---|
BeanManagedUserTransactionStrategy() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
applyTransactionTimeout() |
protected void |
beforeProceed(EntityManagerEntry entityManagerEntry)
Needed because the
EntityManager might get created outside of the UserTransaction
(e.g. depending on the implementation of the producer). |
protected EntityManagerEntry |
createEntityManagerEntry(javax.persistence.EntityManager entityManager,
Class<? extends Annotation> qualifier) |
protected Integer |
getDefaultTransactionTimeoutInSeconds() |
protected javax.persistence.EntityTransaction |
getTransaction(EntityManagerEntry entityManagerEntry) |
protected UserTransaction |
resolveUserTransaction() |
execute, onCloseTransactionScope, prepareException, resolveEntityManagerBeanprotected static final String USER_TRANSACTION_JNDI_NAME
protected EntityManagerEntry createEntityManagerEntry(javax.persistence.EntityManager entityManager, Class<? extends Annotation> qualifier)
createEntityManagerEntry in class ResourceLocalTransactionStrategyprotected void applyTransactionTimeout()
protected Integer getDefaultTransactionTimeoutInSeconds()
protected javax.persistence.EntityTransaction getTransaction(EntityManagerEntry entityManagerEntry)
getTransaction in class ResourceLocalTransactionStrategyentityManagerEntry - entry of the current entity-managerEntityTransaction of the given EntityManager.
A subclass can also return an adapter e.g. for an UserTransactionprotected void beforeProceed(EntityManagerEntry entityManagerEntry)
EntityManager might get created outside of the UserTransaction
(e.g. depending on the implementation of the producer).
Can't be in BeanManagedUserTransactionStrategy.UserTransactionAdapter.begin()
because ResourceLocalTransactionStrategy needs to do
if (!transaction.isActive())
{
transaction.begin();
}
for the EntityTransaction of every EntityManager
and BeanManagedUserTransactionStrategy.UserTransactionAdapter.isActive()
can only use the status information of the UserTransaction and therefore
BeanManagedUserTransactionStrategy.UserTransactionAdapter.begin()
will only executed once, but EntityManager.joinTransaction()
needs to be called for every EntityManager.beforeProceed in class ResourceLocalTransactionStrategyentityManagerEntry - entry of the current entity-managerprotected UserTransaction resolveUserTransaction()
Copyright © 2011-2013 The Apache Software Foundation. All Rights Reserved.