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() ) {
// notify resource that it is being used for tx,
// e.g. this allows the correct physical connection to be
// swapped in for the logical connection.
// The flags parameter can be 0 because the flags are not
// 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(