public void commit(boolean onePhase) throws XAException, IOException {
if (LOG.isDebugEnabled()) {
LOG.debug("XA Transaction commit: " + xid);
}
switch (getState()) {
case START_STATE:
// 1 phase commit, no work done.
checkForPreparedState(onePhase);
setStateFinished();
break;
case IN_USE_STATE:
// 1 phase commit, work done.
checkForPreparedState(onePhase);
doPrePrepare();
setStateFinished();
transactionStore.commit(getTransactionId(), false);
doPostCommit();
break;
case PREPARED_STATE:
// 2 phase commit, work done.
// We would record commit here.
setStateFinished();
transactionStore.commit(getTransactionId(), true);
doPostCommit();
break;
default:
illegalStateTransition("commit");
}
}
|