use of com.sun.enterprise.transaction.api.JavaEETransaction in project Payara by payara.
the class JavaEETransactionManagerSimplified method rollback.
public void rollback() throws IllegalStateException, SecurityException, SystemException {
boolean acquiredlock = false;
try {
JavaEETransaction tx = transactions.get();
if (tx != null && tx.isLocalTx()) {
if (monitoringEnabled) {
// XXX acquireReadLock();
getDelegate().getReadLock().lock();
acquiredlock = true;
}
// rollback local tx
tx.rollback();
} else {
try {
// an XA transaction
getDelegate().rollbackDistributedTransaction();
} finally {
if (tx != null) {
((JavaEETransactionImpl) tx).onTxCompletion(false);
}
}
}
if (requestTracing != null && getRequestTracing().isRequestTracingEnabled()) {
RequestTraceSpanLog spanLog = constructJTAEndSpanLog(tx);
getRequestTracing().addSpanLog(spanLog);
}
} finally {
// clear current thread's tx
setCurrentTransaction(null);
delegates.set(null);
if (acquiredlock) {
// XXX releaseReadLock();
getDelegate().getReadLock().unlock();
}
}
}
use of com.sun.enterprise.transaction.api.JavaEETransaction in project Payara by payara.
the class JavaEETransactionManagerJTSDelegate method getStatus.
public int getStatus() throws SystemException {
JavaEETransaction tx = javaEETM.getCurrentTransaction();
int status = javax.transaction.Status.STATUS_NO_TRANSACTION;
TransactionManager tm = tmLocal.get();
if (tx != null)
status = tx.getStatus();
else if (tm != null)
status = tm.getStatus();
if (_logger.isLoggable(Level.FINE))
_logger.log(Level.FINE, "TM: status: " + JavaEETransactionManagerSimplified.getStatusAsString(status));
return status;
}
use of com.sun.enterprise.transaction.api.JavaEETransaction in project Payara by payara.
the class JavaEETransactionManagerJTSDelegate method getTransaction.
public Transaction getTransaction() throws SystemException {
JavaEETransaction tx = javaEETM.getCurrentTransaction();
if (_logger.isLoggable(Level.FINE))
_logger.log(Level.FINE, "TM: getTransaction: tx=" + tx + ", tm=" + tmLocal.get());
if (tx != null)
return tx;
// Check for a JTS imported tx
TransactionInternal jtsTx = null;
TransactionManager tm = tmLocal.get();
if (tm != null) {
jtsTx = (TransactionInternal) tm.getTransaction();
}
if (jtsTx == null)
return null;
else {
// check if this JTS Transaction was previously active
// in this JVM (possible for distributed loopbacks).
tx = (JavaEETransaction) globalTransactions.get(jtsTx);
if (_logger.isLoggable(Level.FINE))
_logger.log(Level.FINE, "TM: getTransaction: tx=" + tx + ", jtsTx=" + jtsTx);
if (tx == null) {
tx = ((JavaEETransactionManagerSimplified) javaEETM).createImportedTransaction(jtsTx);
globalTransactions.put(jtsTx, tx);
}
// associate tx with thread
javaEETM.setCurrentTransaction(tx);
return tx;
}
}
use of com.sun.enterprise.transaction.api.JavaEETransaction in project Payara by payara.
the class AsynchronousTask method enlistExtendedEntityManagers.
@Override
protected void enlistExtendedEntityManagers(ComponentContext ctx) {
if (ctx.getTransaction() != null) {
JavaEETransaction j2eeTx = (JavaEETransaction) ctx.getTransaction();
SessionContextImpl sessionCtx = (SessionContextImpl) ctx;
Map<EntityManagerFactory, PhysicalEntityManagerWrapper> entityManagerMap = sessionCtx.getExtendedEntityManagerMap();
for (Map.Entry<EntityManagerFactory, PhysicalEntityManagerWrapper> entry : entityManagerMap.entrySet()) {
EntityManagerFactory emf = entry.getKey();
PhysicalEntityManagerWrapper extendedEm = entry.getValue();
PhysicalEntityManagerWrapper extendedEmAssociatedWithTx = EntityManagerWrapper.getExtendedEntityManager(j2eeTx, emf);
// this extended EntityManagerFactory within the current tx
if (extendedEmAssociatedWithTx == null) {
j2eeTx.addExtendedEntityManagerMapping(emf, extendedEm);
sessionCtx.setEmfRegisteredWithTx(emf, true);
// entity manager with the transaction.
if (extendedEm.getSynchronizationType() == SYNCHRONIZED) {
extendedEm.getEM().joinTransaction();
}
}
}
}
}
use of com.sun.enterprise.transaction.api.JavaEETransaction in project Payara by payara.
the class AsynchronousTask method delistExtendedEntityManagers.
@Override
protected void delistExtendedEntityManagers(ComponentContext ctx) {
if (ctx.getTransaction() != null) {
SessionContextImpl sessionCtx = (SessionContextImpl) ctx;
JavaEETransaction j2eeTx = (JavaEETransaction) sessionCtx.getTransaction();
Map<EntityManagerFactory, PhysicalEntityManagerWrapper> entityManagerMap = sessionCtx.getExtendedEntityManagerMap();
for (Map.Entry<EntityManagerFactory, PhysicalEntityManagerWrapper> entry : entityManagerMap.entrySet()) {
EntityManagerFactory emf = entry.getKey();
if (sessionCtx.isEmfRegisteredWithTx(emf)) {
j2eeTx.removeExtendedEntityManagerMapping(emf);
sessionCtx.setEmfRegisteredWithTx(emf, false);
}
}
}
}
Aggregations