throw new XAException(XAException.XAER_INVAL);
}
try {
Transaction txn = getXATransaction(xid);
TxnManager txnMgr = environmentImpl.getTxnManager();
if (flags == XAResource.TMNOFLAGS) {
/*
* If neither RESUME nor JOIN was set, make sure xid doesn't
* exist in allXATxns. Throw XAER_DUPID if it does.
*/
if (txn == null) {
if (DEBUG) {
System.out.println
("Transaction for XID " + xid + " being created");
}
txn = beginTransaction(null, null);
setXATransaction(xid, txn);
} else {
throw new XAException(XAException.XAER_DUPID);
}
} else if (tmJoin) {
if (txn == null) {
throw new XAException(XAException.XAER_NOTA);
}
if (txnMgr.getTxnForThread() != null) {
throw new XAException(XAException.XAER_PROTO);
}
} else if (tmResume) {
if (txn == null) {
throw new XAException(XAException.XAER_NOTA);
}
if (!txn.getTxn().isSuspended()) {
throw new XAException(XAException.XAER_PROTO);
}
txn.getTxn().setSuspended(false);
}
if (DEBUG) {
System.out.println
("Setting Transaction for " + Thread.currentThread());
}
txnMgr.setTxnForThread(txn);
} catch (DatabaseException DE) {
if (DEBUG) {
System.out.println("*** start exception");
}
throwNewXAException(DE);