Search in sources :

Example 1 with TransactionInternal

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;
}
Also used : JavaEETransactionImpl(com.sun.enterprise.transaction.JavaEETransactionImpl) TransactionInternal(com.sun.enterprise.transaction.spi.TransactionInternal)

Example 2 with TransactionInternal

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));
}
Also used : TransactionInternal(com.sun.enterprise.transaction.spi.TransactionInternal)

Example 3 with TransactionInternal

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;
    }
}
Also used : JavaEETransaction(com.sun.enterprise.transaction.api.JavaEETransaction) JavaEETransactionManager(com.sun.enterprise.transaction.api.JavaEETransactionManager) TransactionInternal(com.sun.enterprise.transaction.spi.TransactionInternal)

Aggregations

TransactionInternal (com.sun.enterprise.transaction.spi.TransactionInternal)3 JavaEETransactionImpl (com.sun.enterprise.transaction.JavaEETransactionImpl)1 JavaEETransaction (com.sun.enterprise.transaction.api.JavaEETransaction)1 JavaEETransactionManager (com.sun.enterprise.transaction.api.JavaEETransactionManager)1