use of javax.transaction.InvalidTransactionException in project geode by apache.
the class TransactionManagerImpl method resume.
/**
* @see javax.transaction.TransactionManager#resume(javax.transaction.Transaction)
*/
public void resume(Transaction txn) throws InvalidTransactionException, IllegalStateException, SystemException {
if (!isActive) {
throw new SystemException(LocalizedStrings.TransactionManagerImpl_TRANSACTIONMANAGER_INVALID.toLocalizedString());
}
if (txn == null) {
String exception = LocalizedStrings.TransactionManagerImpl_TRANSACTIONMANAGERIMPL_RESUME_CANNOT_RESUME_A_NULL_TRANSACTION.toLocalizedString();
LogWriterI18n writer = TransactionUtils.getLogWriterI18n();
if (VERBOSE)
writer.fine(exception);
throw new InvalidTransactionException(exception);
}
GlobalTransaction gtx = getGlobalTransaction(txn);
if (gtx == null) {
String exception = LocalizedStrings.TransactionManagerImpl_TRANSACTIONMANAGERIMPL_RESUME_CANNOT_RESUME_A_NULL_TRANSACTION.toLocalizedString();
LogWriterI18n writer = TransactionUtils.getLogWriterI18n();
if (VERBOSE)
writer.fine(exception);
throw new InvalidTransactionException(exception);
}
gtx.resume();
try {
Thread thread = Thread.currentThread();
transactionMap.put(thread, txn);
LogWriterI18n writer = TransactionUtils.getLogWriterI18n();
if (writer.infoEnabled())
writer.info(LocalizedStrings.TransactionManagerImpl_TRANSACTIONMANAGERIMPLRESUMETRANSACTION_RESUMED);
} catch (Exception e) {
String exception = LocalizedStrings.TransactionManagerImpl_TRANSACTIONMANAGERIMPL_RESUME_ERROR_IN_LISTING_THREAD_TO_TRANSACTION_MAP_DUE_TO_0.toLocalizedString(e);
LogWriterI18n writer = TransactionUtils.getLogWriterI18n();
if (VERBOSE)
writer.fine(exception);
throw new SystemException(exception);
}
}
use of javax.transaction.InvalidTransactionException 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 javax.transaction.InvalidTransactionException 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.InvalidTransactionException 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);
}
}
use of javax.transaction.InvalidTransactionException in project wildfly by wildfly.
the class InfinispanBatcher method resumeBatch.
@Override
public BatchContext resumeBatch(TransactionBatch batch) {
TransactionBatch existingBatch = CURRENT_BATCH.get();
// Trivial case - nothing to suspend/resume
if (batch == existingBatch)
return PASSIVE_BATCH_CONTEXT;
Transaction tx = (batch != null) ? batch.getTransaction() : null;
// Non-tx case, just swap thread local
if ((batch == null) || (tx == null)) {
CURRENT_BATCH.set(batch);
return () -> {
CURRENT_BATCH.set(existingBatch);
};
}
try {
if (existingBatch != null) {
Transaction existingTx = this.tm.suspend();
if (existingBatch.getTransaction() != existingTx) {
throw new IllegalStateException();
}
}
this.tm.resume(tx);
CURRENT_BATCH.set(batch);
return () -> {
try {
this.tm.suspend();
if (existingBatch != null) {
try {
this.tm.resume(existingBatch.getTransaction());
CURRENT_BATCH.set(existingBatch);
} catch (InvalidTransactionException e) {
throw new CacheException(e);
}
} else {
CURRENT_BATCH.remove();
}
} catch (SystemException e) {
throw new CacheException(e);
}
};
} catch (SystemException | InvalidTransactionException e) {
throw new CacheException(e);
}
}
Aggregations