use of javax.transaction.TransactionManager in project wildfly by wildfly.
the class CMTTxInterceptor method required.
protected Object required(final InterceptorContext invocation, final EJBComponent component, final int timeout) throws Exception {
final TransactionManager tm = component.getTransactionManager();
if (timeout != -1) {
tm.setTransactionTimeout(timeout);
}
final Transaction tx = tm.getTransaction();
if (tx == null) {
return invokeInOurTx(invocation, tm, component);
} else {
return invokeInCallerTx(invocation, tx, component);
}
}
use of javax.transaction.TransactionManager in project wildfly by wildfly.
the class CMTTxInterceptor method mandatory.
protected Object mandatory(InterceptorContext invocation, final EJBComponent component) throws Exception {
final TransactionManager tm = component.getTransactionManager();
Transaction tx = tm.getTransaction();
if (tx == null) {
throw EjbLogger.ROOT_LOGGER.txRequiredForInvocation(invocation);
}
return invokeInCallerTx(invocation, tx, component);
}
use of javax.transaction.TransactionManager in project wildfly by wildfly.
the class CMTTxInterceptor method supports.
protected Object supports(InterceptorContext invocation, final EJBComponent component) throws Exception {
final TransactionManager tm = component.getTransactionManager();
Transaction tx = tm.getTransaction();
if (tx == null) {
return invokeInNoTx(invocation, component);
} else {
return invokeInCallerTx(invocation, tx, component);
}
}
use of javax.transaction.TransactionManager in project wildfly by wildfly.
the class LifecycleCMTTxInterceptor method notSupported.
@Override
protected Object notSupported(InterceptorContext invocation, EJBComponent component) throws Exception {
TransactionManager tm = component.getTransactionManager();
Transaction tx = tm.getTransaction();
int status = (tx != null) ? tx.getStatus() : Status.STATUS_NO_TRANSACTION;
// then skip suspend/resume of associated tx since JTS refuses to resume a completed tx
switch(status) {
case Status.STATUS_NO_TRANSACTION:
case Status.STATUS_COMMITTED:
case Status.STATUS_ROLLEDBACK:
{
return this.invokeInNoTx(invocation, component);
}
default:
{
Transaction suspendedTx = tm.suspend();
try {
return this.invokeInNoTx(invocation, component);
} finally {
if (suspendedTx != null) {
tm.resume(suspendedTx);
}
}
}
}
}
use of javax.transaction.TransactionManager in project wildfly by wildfly.
the class StatefulBMTInterceptor method handleInvocation.
@Override
protected Object handleInvocation(final InterceptorContext invocation) throws Exception {
final StatefulSessionComponentInstance instance = (StatefulSessionComponentInstance) invocation.getPrivateData(ComponentInstance.class);
TransactionManager tm = getComponent().getTransactionManager();
assert tm.getTransaction() == null : "can't handle BMT transaction, there is a transaction active";
// Is the instance already associated with a transaction?
Transaction tx = instance.getTransaction();
if (tx != null) {
// then resume that transaction.
instance.setTransaction(null);
tm.resume(tx);
}
try {
return invocation.proceed();
} catch (Throwable e) {
throw this.handleException(invocation, e);
} finally {
checkBadStateful();
// Is the instance finished with the transaction?
Transaction newTx = tm.getTransaction();
//always set it, even if null
instance.setTransaction(newTx);
if (newTx != null) {
// remember the association
// and suspend it.
tm.suspend();
}
}
}
Aggregations