@Override
public Transaction getTransaction(final SessionContext context, final TransactionId xid)
throws MetamorphosisException, XAException {
Transaction transaction = null;
if (xid.isXATransaction()) {
synchronized (this.xaTransactions) {
transaction = this.xaTransactions.get(xid);
}
}
else {
transaction = context.getTransactions().get(xid);
}
if (transaction != null) {
return transaction;
}
// �ж��Ƿ��˹��ύ���ع�����
if (xid.isXATransaction()) {
synchronized (this.xaHeuristicTransactions) {
transaction = this.xaHeuristicTransactions.get(xid);
}
if (transaction != null) {
switch (transaction.getState()) {
case Transaction.HEURISTIC_COMMIT_STATE:
XAException e = new XAException("XA transaction '" + xid + "' has been heuristically committed.");
e.errorCode = XAException.XA_HEURCOM;
throw e;
case Transaction.HEURISTIC_ROLLBACK_STATE:
e = new XAException("XA transaction '" + xid + "' has been heuristically rolled back.");
e.errorCode = XAException.XA_HEURRB;
throw e;
case Transaction.HEURISTIC_COMPLETE_STATE:
e = new XAException("XA transaction '" + xid + "' has been heuristically completed.");
e.errorCode = XAException.XA_HEURHAZ;
throw e;
default:
log.warn("Invalid transaction state in xaHeuristicTransactions:" + transaction.getState());
// Ӧ�ò�������������
break;
}
}
}