Search in sources :

Example 11 with ContextTransactionManager

use of org.wildfly.transaction.client.ContextTransactionManager in project wildfly by wildfly.

the class CMTTxInterceptor method mandatory.

protected Object mandatory(InterceptorContext invocation, final EJBComponent component) throws Exception {
    final ContextTransactionManager tm = ContextTransactionManager.getInstance();
    Transaction tx = tm.getTransaction();
    if (tx == null) {
        if (invocation.hasTransaction()) {
            return invokeInImportedTx(invocation, component);
        }
        throw EjbLogger.ROOT_LOGGER.txRequiredForInvocation(invocation);
    }
    return invokeInCallerTx(invocation, tx, component);
}
Also used : ContextTransactionManager(org.wildfly.transaction.client.ContextTransactionManager) AbstractTransaction(org.wildfly.transaction.client.AbstractTransaction) Transaction(javax.transaction.Transaction)

Example 12 with ContextTransactionManager

use of org.wildfly.transaction.client.ContextTransactionManager in project wildfly by wildfly.

the class CMTTxInterceptor method supports.

protected Object supports(InterceptorContext invocation, final EJBComponent component) throws Exception {
    final ContextTransactionManager tm = ContextTransactionManager.getInstance();
    Transaction tx = tm.getTransaction();
    if (tx == null) {
        if (invocation.hasTransaction()) {
            return invokeInImportedTx(invocation, component);
        }
        return invokeInNoTx(invocation, component);
    } else {
        return invokeInCallerTx(invocation, tx, component);
    }
}
Also used : ContextTransactionManager(org.wildfly.transaction.client.ContextTransactionManager) AbstractTransaction(org.wildfly.transaction.client.AbstractTransaction) Transaction(javax.transaction.Transaction)

Example 13 with ContextTransactionManager

use of org.wildfly.transaction.client.ContextTransactionManager in project wildfly by wildfly.

the class BMTInterceptor method processInvocation.

@Override
public Object processInvocation(final InterceptorContext context) throws Exception {
    final ContextTransactionManager tm = ContextTransactionManager.getInstance();
    final int oldTimeout = tm.getTransactionTimeout();
    try {
        Transaction oldTx = tm.suspend();
        try {
            return handleInvocation(context);
        } finally {
            if (oldTx != null)
                tm.resume(oldTx);
        }
    } finally {
        // See also https://issues.jboss.org/browse/WFTC-44
        tm.setTransactionTimeout(oldTimeout == ContextTransactionManager.getGlobalDefaultTransactionTimeout() ? 0 : oldTimeout);
    }
}
Also used : ContextTransactionManager(org.wildfly.transaction.client.ContextTransactionManager) Transaction(javax.transaction.Transaction)

Example 14 with ContextTransactionManager

use of org.wildfly.transaction.client.ContextTransactionManager in project wildfly by wildfly.

the class TransactionUtil method registerSynchronization.

public static void registerSynchronization(EntityManager entityManager, String puScopedName, TransactionSynchronizationRegistry tsr, TransactionManager transactionManager) {
    SessionSynchronization sessionSynchronization = new SessionSynchronization(entityManager, puScopedName);
    tsr.registerInterposedSynchronization(sessionSynchronization);
    final AbstractTransaction transaction = ((ContextTransactionManager) transactionManager).getTransaction();
    doPrivileged((PrivilegedAction<Void>) () -> {
        transaction.registerAssociationListener(sessionSynchronization);
        return null;
    });
}
Also used : ContextTransactionManager(org.wildfly.transaction.client.ContextTransactionManager) AbstractTransaction(org.wildfly.transaction.client.AbstractTransaction)

Aggregations

ContextTransactionManager (org.wildfly.transaction.client.ContextTransactionManager)14 Transaction (javax.transaction.Transaction)7 AbstractTransaction (org.wildfly.transaction.client.AbstractTransaction)7 RollbackException (javax.transaction.RollbackException)4 SystemException (javax.transaction.SystemException)4 StartException (org.jboss.msc.service.StartException)4 EJBException (javax.ejb.EJBException)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 HeuristicMixedException (javax.transaction.HeuristicMixedException)2 HeuristicRollbackException (javax.transaction.HeuristicRollbackException)2 EJBComponent (org.jboss.as.ejb3.component.EJBComponent)2 ZeroPortPolicy (com.sun.corba.se.spi.extension.ZeroPortPolicy)1 InvalidClassException (java.io.InvalidClassException)1 Method (java.lang.reflect.Method)1 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 RemoteException (java.rmi.RemoteException)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 SQLException (java.sql.SQLException)1