use of javax.transaction.SystemException in project wildfly by wildfly.
the class FileTimerPersistence method mostRecentEntityVersion.
/**
* Returns either the loaded entity or the most recent version of the entity that has
* been persisted in this transaction.
*/
private TimerImpl mostRecentEntityVersion(final TimerImpl timerImpl) {
try {
final int status = transactionManager.getValue().getStatus();
if (status == Status.STATUS_UNKNOWN || status == Status.STATUS_NO_TRANSACTION) {
return timerImpl;
}
final String key = timerTransactionKey(timerImpl);
TimerImpl existing = (TimerImpl) transactionSynchronizationRegistry.getValue().getResource(key);
return existing != null ? existing : timerImpl;
} catch (SystemException e) {
throw new RuntimeException(e);
}
}
use of javax.transaction.SystemException in project wildfly by wildfly.
the class StatefulBMTInterceptor method checkBadStateful.
private void checkBadStateful() {
int status = Status.STATUS_NO_TRANSACTION;
TransactionManager tm = getComponent().getTransactionManager();
try {
status = tm.getStatus();
} catch (SystemException ex) {
EjbLogger.ROOT_LOGGER.failedToGetStatus(ex);
}
switch(status) {
case Status.STATUS_COMMITTING:
case Status.STATUS_MARKED_ROLLBACK:
case Status.STATUS_PREPARING:
case Status.STATUS_ROLLING_BACK:
try {
tm.rollback();
} catch (Exception ex) {
EjbLogger.ROOT_LOGGER.failedToRollback(ex);
}
EjbLogger.ROOT_LOGGER.transactionNotComplete(getComponent().getComponentName(), statusAsString(status));
}
}
use of javax.transaction.SystemException 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);
}
}
use of javax.transaction.SystemException in project wildfly by wildfly.
the class InfinispanBatcher method createBatch.
@Override
public TransactionBatch createBatch() {
if (this.tm == null)
return NON_TX_BATCH;
TransactionBatch batch = CURRENT_BATCH.get();
if (batch != null) {
return batch.interpose();
}
try {
this.tm.suspend();
this.tm.begin();
Transaction tx = this.tm.getTransaction();
tx.registerSynchronization(CURRENT_BATCH_REMOVER);
batch = new InfinispanBatch(tx);
CURRENT_BATCH.set(batch);
return batch;
} catch (RollbackException | SystemException | NotSupportedException e) {
throw new CacheException(e);
}
}
use of javax.transaction.SystemException in project wildfly by wildfly.
the class EJBComponent method setRollbackOnly.
public void setRollbackOnly() throws IllegalStateException {
if (isBeanManagedTransaction()) {
throw EjbLogger.ROOT_LOGGER.failToCallSetRollbackOnlyOnNoneCMB();
}
try {
// get the transaction manager
TransactionManager tm = getTransactionManager();
// check if there's a tx in progress. If not, then it's an error to call setRollbackOnly()
if (tm.getTransaction() == null) {
throw EjbLogger.ROOT_LOGGER.failToCallSetRollbackOnlyWithNoTx();
}
// set rollback
tm.setRollbackOnly();
} catch (SystemException se) {
EjbLogger.ROOT_LOGGER.setRollbackOnlyFailed(se);
}
}
Aggregations