Search in sources :

Example 1 with JavaEETransactionManagerDelegate

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

the class AppTest method setUp.

public void setUp() {
    try {
        t = new JavaEETransactionManagerSimplified();
        JavaEETransactionManagerDelegate d = new JavaEETransactionManagerJTSDelegate();
        t.setDelegate(d);
        d.setTransactionManager(t);
    } catch (Exception ex) {
        ex.printStackTrace();
        assert (false);
    }
}
Also used : JavaEETransactionManagerDelegate(com.sun.enterprise.transaction.spi.JavaEETransactionManagerDelegate) JavaEETransactionManagerSimplified(com.sun.enterprise.transaction.JavaEETransactionManagerSimplified) TimeoutException(java.util.concurrent.TimeoutException)

Example 2 with JavaEETransactionManagerDelegate

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

the class AppTest method setUp.

public void setUp() {
    try {
        t = new JavaEETransactionManagerSimplified();
        JavaEETransactionManagerDelegate d = new JavaEETransactionManagerSimplifiedDelegate();
        t.setDelegate(d);
        d.setTransactionManager(t);
    } catch (Exception ex) {
        ex.printStackTrace();
        assert (false);
    }
}
Also used : JavaEETransactionManagerDelegate(com.sun.enterprise.transaction.spi.JavaEETransactionManagerDelegate)

Example 3 with JavaEETransactionManagerDelegate

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

the class AppTest method testReplaceDelegate.

/**
 * Test that you can't replace delegate with a lower order.
 */
public void testReplaceDelegate() {
    JavaEETransactionManagerDelegate d = new JavaEETransactionManagerSimplifiedDelegate();
    t.setDelegate(d);
    assertFalse(((JavaEETransactionManagerSimplified) t).isDelegate(d));
}
Also used : JavaEETransactionManagerDelegate(com.sun.enterprise.transaction.spi.JavaEETransactionManagerDelegate) JavaEETransactionManagerSimplifiedDelegate(com.sun.enterprise.transaction.JavaEETransactionManagerSimplifiedDelegate)

Example 4 with JavaEETransactionManagerDelegate

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

the class JavaEETransactionManagerSimplified method enlistResource.

public boolean enlistResource(Transaction tran, TransactionalResource h) throws RollbackException, IllegalStateException, SystemException {
    if (_logger.isLoggable(Level.FINE)) {
        _logger.log(Level.FINE, "\n\nIn JavaEETransactionManagerSimplified.enlistResource, h=" + h + " h.xares=" + h.getXAResource() + /**
         * +" h.alloc=" +h.getResourceAllocator() *
         */
        " tran=" + tran);
    }
    if (!h.isTransactional())
        return true;
    // If LazyEnlistment is suspended, do not enlist resource.
    if (h.isEnlistmentSuspended()) {
        return false;
    }
    if (monitoringEnabled) {
        JavaEETransaction tx = getDelegate().getJavaEETransaction(tran);
        if (tx != null) {
            ((JavaEETransactionImpl) tx).addResourceName(h.getName());
        }
    }
    if (!(tran instanceof JavaEETransaction)) {
        return enlistXAResource(tran, h);
    }
    JavaEETransactionImpl tx = (JavaEETransactionImpl) tran;
    JavaEETransactionManagerDelegate d = setDelegate();
    boolean useLAO = d.useLAO();
    if ((tx.getNonXAResource() != null) && (!useLAO || !h.supportsXA())) {
        boolean isSameRM = false;
        try {
            isSameRM = h.getXAResource().isSameRM(tx.getNonXAResource().getXAResource());
            if (_logger.isLoggable(Level.FINE)) {
                _logger.log(Level.FINE, "\n\nIn JavaEETransactionManagerSimplified.enlistResource, isSameRM? " + isSameRM);
            }
        } catch (XAException xex) {
            throw new SystemException(sm.getString("enterprise_distributedtx.samerm_excep", xex));
        } catch (Exception ex) {
            throw new SystemException(sm.getString("enterprise_distributedtx.samerm_excep", ex));
        }
        if (!isSameRM) {
            throw new IllegalStateException(sm.getString("enterprise_distributedtx.already_has_nonxa"));
        }
    }
    if (h.supportsXA()) {
        if (!d.supportsXAResource()) {
            throw new IllegalStateException(sm.getString("enterprise_distributedtx.xaresource_not_supported"));
        }
        if (tx.isLocalTx()) {
            d.enlistLAOResource(tx, tx.getNonXAResource());
        /**
         * XXX TO BE MOVED TO XA DELEGATE XXX **
         *               startJTSTx(tx);
         *
         *               //If transaction conatains a NonXA and no LAO, convert the existing
         *               //Non XA to LAO
         *               if(useLAO) {
         *                   if(tx.getNonXAResource()!=null && (tx.getLAOResource()==null) ) {
         *                       tx.setLAOResource(tx.getNonXAResource());
         *                       // XXX super.enlistLAOResource(tx, tx.getNonXAResource());
         *                   }
         *               }
         ** XXX TO BE MOVED TO XA DELEGATE XXX *
         */
        }
        return enlistXAResource(tx, h);
    } else {
        // non-XA resource
        if (tx.isImportedTransaction())
            throw new IllegalStateException(sm.getString("enterprise_distributedtx.nonxa_usein_jts"));
        if (tx.getNonXAResource() == null) {
            tx.setNonXAResource(h);
        }
        if (tx.isLocalTx()) {
            // used by the XAResource implementation for non-XA resources.
            try {
                h.getXAResource().start(tx.getLocalXid(), 0);
            } catch (XAException ex) {
                throw new RuntimeException(sm.getString("enterprise_distributedtx.xaresource_start_excep"), ex);
            }
            h.enlistedInTransaction(tx);
            return true;
        } else {
            return d.enlistDistributedNonXAResource(tx, h);
        /**
         * XXX TO BE MOVED TO XA DELEGATE? XXX
         *                if(useLAO) {
         *                    return super.enlistResource(tx, h);
         *                } else {
         *                    throw new IllegalStateException(
         *                            sm.getString("enterprise_distributedtx.nonxa_usein_jts"));
         *                }
         ** XXX TO BE MOVED TO XA DELEGATE? XXX *
         */
        }
    }
}
Also used : JavaEETransactionManagerDelegate(com.sun.enterprise.transaction.spi.JavaEETransactionManagerDelegate) XAException(javax.transaction.xa.XAException) JavaEETransaction(com.sun.enterprise.transaction.api.JavaEETransaction) InvocationException(org.glassfish.api.invocation.InvocationException) WorkException(javax.resource.spi.work.WorkException) RemoteException(java.rmi.RemoteException) XAException(javax.transaction.xa.XAException)

Example 5 with JavaEETransactionManagerDelegate

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

the class JavaEETransactionManagerSimplified method setDelegate.

private JavaEETransactionManagerDelegate setDelegate() {
    JavaEETransactionManagerDelegate d = delegates.get();
    if (d == null) {
        d = delegate;
        delegates.set(d);
    }
    return d;
}
Also used : JavaEETransactionManagerDelegate(com.sun.enterprise.transaction.spi.JavaEETransactionManagerDelegate)

Aggregations

JavaEETransactionManagerDelegate (com.sun.enterprise.transaction.spi.JavaEETransactionManagerDelegate)5 JavaEETransactionManagerSimplified (com.sun.enterprise.transaction.JavaEETransactionManagerSimplified)1 JavaEETransactionManagerSimplifiedDelegate (com.sun.enterprise.transaction.JavaEETransactionManagerSimplifiedDelegate)1 JavaEETransaction (com.sun.enterprise.transaction.api.JavaEETransaction)1 RemoteException (java.rmi.RemoteException)1 TimeoutException (java.util.concurrent.TimeoutException)1 WorkException (javax.resource.spi.work.WorkException)1 XAException (javax.transaction.xa.XAException)1 InvocationException (org.glassfish.api.invocation.InvocationException)1