use of org.wildfly.transaction.client.LocalTransaction in project wildfly by wildfly.
the class JBossContextXATerminator method startWork.
/**
* <p>
* Start work gets imported transaction and assign it to current thread.
* <p>
* This method mimics behavior of Narayana's {@link JBossXATerminator}.
*/
@Override
public void startWork(Work work, Xid xid) throws WorkCompletedException {
LocalTransaction transaction = null;
try {
ImportResult<LocalTransaction> transactionImportResult = localTransactionContext.findOrImportTransaction(xid, 0);
transaction = transactionImportResult.getTransaction();
ContextTransactionManager.getInstance().resume(transaction);
} catch (XAException xae) {
throw TransactionLogger.ROOT_LOGGER.cannotFindOrImportInflowTransaction(xid, work, xae);
} catch (InvalidTransactionException ite) {
throw TransactionLogger.ROOT_LOGGER.importedInflowTransactionIsInactive(xid, work, ite);
} catch (SystemException se) {
throw TransactionLogger.ROOT_LOGGER.cannotResumeInflowTransactionUnexpectedError(transaction, work, se);
}
}
use of org.wildfly.transaction.client.LocalTransaction in project wildfly by wildfly.
the class LifecycleCMTTxInterceptor method beginTransaction.
protected Transaction beginTransaction(final TransactionManager tm) throws NotSupportedException, SystemException {
if (tm instanceof ContextTransactionManager) {
final ContextTransactionManager contextTransactionManager = (ContextTransactionManager) tm;
int timeout = contextTransactionManager.getTransactionTimeout();
final LocalTransaction transaction = LocalTransactionContext.getCurrent().beginTransaction(timeout, false);
try {
contextTransactionManager.resume(transaction);
} catch (InvalidTransactionException e) {
// should not be possible
throw new IllegalStateException(e);
}
return transaction;
} else {
return super.beginTransaction(tm);
}
}
Aggregations