Search in sources :

Example 1 with JavaEETransactionImpl

use of com.sun.enterprise.transaction.JavaEETransactionImpl 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 JavaEETransactionImpl

use of com.sun.enterprise.transaction.JavaEETransactionImpl in project Payara by payara.

the class JavaEETransactionManagerJTSDelegate method getTransactionAdminBean.

public TransactionAdminBean getTransactionAdminBean(Transaction t) throws javax.transaction.SystemException {
    TransactionAdminBean tBean = null;
    if (t instanceof com.sun.jts.jta.TransactionImpl) {
        String id = ((com.sun.jts.jta.TransactionImpl) t).getTransactionId();
        long startTime = ((com.sun.jts.jta.TransactionImpl) t).getStartTime();
        long elapsedTime = System.currentTimeMillis() - startTime;
        String status = JavaEETransactionManagerSimplified.getStatusAsString(t.getStatus());
        JavaEETransactionImpl tran = (JavaEETransactionImpl) globalTransactions.get(t);
        if (tran != null) {
            tBean = ((JavaEETransactionManagerSimplified) javaEETM).getTransactionAdminBean(tran);
            // Override with JTS values
            tBean.setIdentifier(t);
            tBean.setId(id);
            tBean.setStatus(status);
            tBean.setElapsedTime(elapsedTime);
            if (tBean.getComponentName() == null) {
                tBean.setComponentName("unknown");
            }
        } else {
            tBean = new TransactionAdminBean(t, id, status, elapsedTime, "unknown", null);
        }
    } else {
        tBean = ((JavaEETransactionManagerSimplified) javaEETM).getTransactionAdminBean(t);
    }
    return tBean;
}
Also used : JavaEETransactionImpl(com.sun.enterprise.transaction.JavaEETransactionImpl) TransactionAdminBean(com.sun.enterprise.transaction.api.TransactionAdminBean) JavaEETransactionImpl(com.sun.enterprise.transaction.JavaEETransactionImpl)

Aggregations

JavaEETransactionImpl (com.sun.enterprise.transaction.JavaEETransactionImpl)2 TransactionAdminBean (com.sun.enterprise.transaction.api.TransactionAdminBean)1 TransactionInternal (com.sun.enterprise.transaction.spi.TransactionInternal)1