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);
}
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);
}
}
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);
}
}
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;
});
}
Aggregations