Search in sources :

Example 6 with SuspendedTransaction

use of org.apache.openejb.core.transaction.BeanTransactionPolicy.SuspendedTransaction in project tomee by apache.

the class StatefulContainer method afterInvoke.

private void afterInvoke(final ThreadContext callContext, final TransactionPolicy txPolicy, final Instance instance) throws OpenEJBException {
    try {
        if (instance != null && txPolicy instanceof BeanTransactionPolicy) {
            // suspend the currently running transaction if any
            SuspendedTransaction suspendedTransaction = null;
            try {
                final BeanTransactionPolicy beanTxEnv = (BeanTransactionPolicy) txPolicy;
                suspendedTransaction = beanTxEnv.suspendUserTransaction();
            } catch (final SystemException e) {
                EjbTransactionUtil.handleSystemException(txPolicy, e, callContext);
            } finally {
                instance.setBeanTransaction(suspendedTransaction);
            }
        }
    } finally {
        if (instance != null) {
            instance.setInUse(false);
        }
        EjbTransactionUtil.afterInvoke(txPolicy, callContext);
        if (instance != null) {
            instance.releaseLock();
        }
    }
}
Also used : BeanTransactionPolicy(org.apache.openejb.core.transaction.BeanTransactionPolicy) SystemException(org.apache.openejb.SystemException) SuspendedTransaction(org.apache.openejb.core.transaction.BeanTransactionPolicy.SuspendedTransaction)

Aggregations

BeanTransactionPolicy (org.apache.openejb.core.transaction.BeanTransactionPolicy)6 SuspendedTransaction (org.apache.openejb.core.transaction.BeanTransactionPolicy.SuspendedTransaction)6 Method (java.lang.reflect.Method)4 ThreadContext (org.apache.openejb.core.ThreadContext)4 InterceptorData (org.apache.openejb.core.interceptor.InterceptorData)4 InterceptorStack (org.apache.openejb.core.interceptor.InterceptorStack)4 JtaTransactionPolicy (org.apache.openejb.core.transaction.JtaTransactionPolicy)4 TransactionPolicy (org.apache.openejb.core.transaction.TransactionPolicy)4 SystemInstance (org.apache.openejb.loader.SystemInstance)4 BeanContext (org.apache.openejb.BeanContext)3 EJBHome (javax.ejb.EJBHome)2 EJBLocalHome (javax.ejb.EJBLocalHome)2 RemoveException (javax.ejb.RemoveException)2 SessionBean (javax.ejb.SessionBean)2 LoginException (javax.security.auth.login.LoginException)2 ApplicationException (org.apache.openejb.ApplicationException)2 InvalidateReferenceException (org.apache.openejb.InvalidateReferenceException)2 SystemException (org.apache.openejb.SystemException)2 Dependent (javax.enterprise.context.Dependent)1 EntityManagerFactory (javax.persistence.EntityManagerFactory)1