public synchronized void commit(final Xid xid, final boolean onePhase) throws XAException {
if (xid == null) {
throw new XAException(XAException.XAER_INVAL);
}
TransactionContext tx;
tx = (TransactionContext) _engine.getXATransactions().get(xid);
if (tx == null) {
throw new XAException(XAException.XAER_NOTA);
}
switch (tx.getStatus()) {
case Status.STATUS_COMMITTED:
// Allowed to make multiple commit attempts.
return;
case Status.STATUS_ROLLEDBACK:
// This should not happen unless someone interfered
// by calling rollback directly or failing a commit,
// but is still a valid heuristic condition on our behalf.
throw new XAException(XAException.XA_HEURRB);
case Status.STATUS_PREPARED:
// Commit can only occur after a prepare, so must be
// in prepared state first. Any ODMG error is reported
// as a heuristic decision to rollback.
try {
tx.commit();
} catch (TransactionAbortedException except) {
// Transaction cannot commit and was rolledback
throw new XAException(XAException.XA_HEURRB);
} catch (IllegalStateException except) {
throw new XAException(XAException.XAER_PROTO);