use of javax.transaction.TransactionManager in project wildfly by wildfly.
the class MessageEndpointInvocationHandler method afterDelivery.
@Override
public void afterDelivery() throws ResourceException {
final TransactionManager tm = getTransactionManager();
try {
if (currentTx != null) {
if (currentTx.getStatus() == Status.STATUS_MARKED_ROLLBACK)
tm.rollback();
else
tm.commit();
currentTx = null;
}
if (previousTx != null) {
tm.resume(previousTx);
previousTx = null;
}
} catch (InvalidTransactionException e) {
throw new LocalTransactionException(e);
} catch (HeuristicMixedException e) {
throw new LocalTransactionException(e);
} catch (SystemException e) {
throw new LocalTransactionException(e);
} catch (HeuristicRollbackException e) {
throw new LocalTransactionException(e);
} catch (RollbackException e) {
throw new LocalTransactionException(e);
} finally {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(previousClassLoader);
previousClassLoader = null;
}
}
use of javax.transaction.TransactionManager in project wildfly by wildfly.
the class CMTTxInterceptor method processInvocation.
public Object processInvocation(InterceptorContext invocation) throws Exception {
final EJBComponent component = (EJBComponent) invocation.getPrivateData(Component.class);
final TransactionManager tm = component.getTransactionManager();
final int oldTimeout = getCurrentTransactionTimeout(component);
try {
final MethodIntf methodIntf = MethodIntfHelper.of(invocation);
final TransactionAttributeType attr = component.getTransactionAttributeType(methodIntf, invocation.getMethod());
final int timeoutInSeconds = component.getTransactionTimeout(methodIntf, invocation.getMethod());
switch(attr) {
case MANDATORY:
return mandatory(invocation, component);
case NEVER:
return never(invocation, component);
case NOT_SUPPORTED:
return notSupported(invocation, component);
case REQUIRED:
return required(invocation, component, timeoutInSeconds);
case REQUIRES_NEW:
return requiresNew(invocation, component, timeoutInSeconds);
case SUPPORTS:
return supports(invocation, component);
default:
throw EjbLogger.ROOT_LOGGER.unknownTxAttributeOnInvocation(attr, invocation);
}
} finally {
tm.setTransactionTimeout(oldTimeout == -1 ? 0 : oldTimeout);
}
}
use of javax.transaction.TransactionManager in project wildfly by wildfly.
the class CMTTxInterceptor method notSupported.
protected Object notSupported(InterceptorContext invocation, final EJBComponent component) throws Exception {
final TransactionManager tm = component.getTransactionManager();
Transaction tx = tm.getTransaction();
if (tx != null) {
tm.suspend();
try {
return invokeInNoTx(invocation, component);
} finally {
tm.resume(tx);
}
} else {
return invokeInNoTx(invocation, component);
}
}
use of javax.transaction.TransactionManager in project wildfly by wildfly.
the class CMTTxInterceptor method requiresNew.
protected Object requiresNew(InterceptorContext invocation, final EJBComponent component, final int timeout) throws Exception {
final TransactionManager tm = component.getTransactionManager();
if (timeout != -1) {
tm.setTransactionTimeout(timeout);
}
Transaction tx = tm.getTransaction();
if (tx != null) {
tm.suspend();
try {
return invokeInOurTx(invocation, tm, component);
} finally {
tm.resume(tx);
}
} else {
return invokeInOurTx(invocation, tm, component);
}
}
use of javax.transaction.TransactionManager in project wildfly by wildfly.
the class EjbBMTInterceptor method handleInvocation.
@Override
protected Object handleInvocation(final InterceptorContext invocation) throws Exception {
final EJBComponent ejbComponent = getComponent();
TransactionManager tm = ejbComponent.getTransactionManager();
assert tm.getTransaction() == null : "can't handle BMT transaction, there is a transaction active";
boolean exceptionThrown = false;
try {
return invocation.proceed();
} catch (Throwable ex) {
exceptionThrown = true;
checkStatelessDone(ejbComponent, invocation, tm, ex);
//we should never get here, as checkStatelessDone should re-throw
throw (Exception) ex;
} finally {
try {
if (!exceptionThrown)
checkStatelessDone(ejbComponent, invocation, tm, null);
} finally {
tm.suspend();
}
}
}
Aggregations