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);
}
}
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);
}
}
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));
}
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 *
*/
}
}
}
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;
}
Aggregations