public void start(Xid xid, int flags) throws XAException {
if (isAssociated()) {
log.error("Resource already associated with a transaction.");
throw new XAException(XAException.XAER_PROTO);
}
TransactionContext tx = txGlobal.get(xid);
if (flags == TMNOFLAGS) {
if (tx != null) {
throw new XAException(XAException.XAER_DUPID);
}
tx = createTransaction(xid);
} else if (flags == TMJOIN) {
if (tx == null) {
throw new XAException(XAException.XAER_NOTA);
}
} else if (flags == TMRESUME) {
if (tx == null) {
throw new XAException(XAException.XAER_NOTA);
}
if (!tx.isSuspended()) {
log.error("Unable to resume: transaction not suspended.");
throw new XAException(XAException.XAER_PROTO);
}
tx.setSuspended(false);
} else {
throw new XAException(XAException.XAER_INVAL);
}
associate(tx);