use of com.sun.enterprise.transaction.spi.TransactionInternal in project Payara by payara.
the class JavaEETransactionManagerJTSDelegate method startJTSTx.
public TransactionInternal startJTSTx(JavaEETransaction tran, boolean isAssociatedTimeout) throws RollbackException, IllegalStateException, SystemException {
setTransactionManager();
JavaEETransactionImpl tx = (JavaEETransactionImpl) tran;
try {
if (isAssociatedTimeout) {
// calculate the timeout for the transaction, this is required as the local tx
// is getting converted to a global transaction
int timeout = tx.cancelTimerTask();
int newtimeout = (int) ((System.currentTimeMillis() - tx.getStartTime()) / 1000);
newtimeout = (timeout - newtimeout);
beginJTS(newtimeout);
} else {
beginJTS(((JavaEETransactionManagerSimplified) javaEETM).getEffectiveTimeout());
}
} catch (NotSupportedException ex) {
throw new RuntimeException(sm.getString("enterprise_distributedtx.lazy_transaction_notstarted"), ex);
}
TransactionInternal jtsTx = (TransactionInternal) tmLocal.get().getTransaction();
globalTransactions.put(jtsTx, tx);
return jtsTx;
}
use of com.sun.enterprise.transaction.spi.TransactionInternal in project Payara by payara.
the class JavaEETransactionManagerSimplified method startJTSTx.
public void startJTSTx(JavaEETransaction t) throws RollbackException, IllegalStateException, SystemException {
JavaEETransactionImpl tx = (JavaEETransactionImpl) t;
TransactionInternal jtsTx = getDelegate().startJTSTx(tx, tx.isAssociatedTimeout());
// The local Transaction was promoted to global Transaction
if (monitoringEnabled) {
if (activeTransactions.remove(tx)) {
monitor.transactionDeactivatedEvent();
}
}
tx.setJTSTx(jtsTx);
jtsTx.registerSynchronization(new JTSSynchronization(jtsTx, this));
}
use of com.sun.enterprise.transaction.spi.TransactionInternal 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;
}
}
Aggregations