use of javax.transaction.Transaction in project wildfly by wildfly.
the class InboundBridgeResource method enlistXAResource.
@POST
@Transactional
public Response enlistXAResource() {
if (LOG.isTraceEnabled()) {
LOG.trace("InboundBridgeResource.enlistXAResource()");
}
try {
loggingXAResource = new LoggingXAResource();
Transaction t = TransactionManager.transactionManager().getTransaction();
t.enlistResource(loggingXAResource);
} catch (Exception e) {
LOG.warn(e.getMessage(), e);
return Response.serverError().build();
}
return Response.ok().build();
}
use of javax.transaction.Transaction in project wildfly by wildfly.
the class JCAOrderedLastSynchronizationList method afterCompletion.
@Override
public void afterCompletion(int status) {
// https://github.com/jbosstm/narayana/blob/master/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TwoPhaseCoordinator.java#L509
for (int i = preJcaSyncs.size() - 1; i >= 0; --i) {
Synchronization preJcaSync = preJcaSyncs.get(i);
if (TransactionLogger.ROOT_LOGGER.isTraceEnabled()) {
TransactionLogger.ROOT_LOGGER.trace("JCAOrderedLastSynchronizationList.preJcaSyncs.afterCompletion - Class: " + preJcaSync.getClass() + " HashCode: " + preJcaSync.hashCode() + " toString: " + preJcaSync);
}
try {
preJcaSync.afterCompletion(status);
} catch (Exception e) {
// Trap these exceptions so the rest of the synchronizations get the chance to complete
// https://github.com/jbosstm/narayana/blob/5.0.4.Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore/SynchronizationImple.java#L102
TransactionLogger.ROOT_LOGGER.preJcaSyncAfterCompletionFailed(preJcaSync, tx, e);
}
}
for (int i = jcaSyncs.size() - 1; i >= 0; --i) {
Synchronization jcaSync = jcaSyncs.get(i);
if (TransactionLogger.ROOT_LOGGER.isTraceEnabled()) {
TransactionLogger.ROOT_LOGGER.trace("JCAOrderedLastSynchronizationList.jcaSyncs.afterCompletion - Class: " + jcaSync.getClass() + " HashCode: " + jcaSync.hashCode() + " toString: " + jcaSync);
}
try {
jcaSync.afterCompletion(status);
} catch (Exception e) {
// Trap these exceptions so the rest of the synchronizations get the chance to complete
// https://github.com/jbosstm/narayana/blob/5.0.4.Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore/SynchronizationImple.java#L102
TransactionLogger.ROOT_LOGGER.jcaSyncAfterCompletionFailed(jcaSync, tx, e);
}
}
if (jcaOrderedLastSynchronizations.remove(tx) == null) {
// The identifier wasn't stable - scan for it - this can happen in JTS propagation when the UID needs retrieving
// from the parent and the parent has been deactivated
Transaction altKey = null;
Iterator<Entry<Transaction, JCAOrderedLastSynchronizationList>> iterator = jcaOrderedLastSynchronizations.entrySet().iterator();
while (altKey == null && iterator.hasNext()) {
Map.Entry<Transaction, JCAOrderedLastSynchronizationList> next = iterator.next();
if (next.getValue().equals(this)) {
altKey = next.getKey();
iterator.remove();
if (TransactionLogger.ROOT_LOGGER.isTraceEnabled()) {
TransactionLogger.ROOT_LOGGER.tracef("Removed: %s [%s]", System.identityHashCode(tx), tx.toString());
}
break;
}
}
if (altKey == null) {
TransactionLogger.ROOT_LOGGER.transactionNotFound(tx);
}
}
}
use of javax.transaction.Transaction in project wildfly by wildfly.
the class TransactionSynchronizationRegistryWrapper method registerInterposedSynchronization.
@Override
public void registerInterposedSynchronization(Synchronization sync) throws IllegalStateException {
try {
Transaction tx = transactionManager.getTransaction();
JCAOrderedLastSynchronizationList jcaOrderedLastSynchronization = interposedSyncs.get(tx);
if (jcaOrderedLastSynchronization == null) {
JCAOrderedLastSynchronizationList toPut = new JCAOrderedLastSynchronizationList((com.arjuna.ats.jta.transaction.Transaction) tx, interposedSyncs);
jcaOrderedLastSynchronization = interposedSyncs.putIfAbsent(tx, toPut);
if (jcaOrderedLastSynchronization == null) {
jcaOrderedLastSynchronization = toPut;
delegate.registerInterposedSynchronization(jcaOrderedLastSynchronization);
}
}
jcaOrderedLastSynchronization.registerInterposedSynchronization(sync);
} catch (SystemException e) {
throw new IllegalStateException(e);
}
}
use of javax.transaction.Transaction in project wildfly by wildfly.
the class TimerServiceImpl method registerSynchronization.
private void registerSynchronization(Synchronization synchronization) {
try {
final Transaction tx = this.getTransaction();
// register for lifecycle events of transaction
tx.registerSynchronization(synchronization);
} catch (RollbackException e) {
throw new EJBException(e);
} catch (SystemException e) {
throw new EJBException(e);
}
}
use of javax.transaction.Transaction 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);
}
}
Aggregations