transactions.removeTransactionContext(threadId);
}
}
private TransactionContext checkXAState(final String threadId, final XidImpl xid, boolean transactionExpected, boolean threadBound) throws XATransactionException {
TransactionContext tc = transactions.getTransactionContext(xid);
if (transactionExpected && tc == null) {
throw new XATransactionException(XAException.XAER_NOTA, QueryPlugin.Util.getString("TransactionServer.no_global_transaction", xid)); //$NON-NLS-1$
} else if (!transactionExpected) {
if (tc != null) {
throw new XATransactionException(XAException.XAER_DUPID, QueryPlugin.Util.getString("TransactionServer.existing_global_transaction", new Object[] {xid})); //$NON-NLS-1$
}
if (!threadBound) {
tc = transactions.getOrCreateTransactionContext(threadId);
if (tc.getTransactionType() != TransactionContext.Scope.NONE) {
throw new XATransactionException(XAException.XAER_PROTO, QueryPlugin.Util.getString("TransactionServer.existing_transaction", new Object[] {xid, threadId})); //$NON-NLS-1$
}
}
return null;
}
if (threadBound) {
if (!threadId.equals(tc.getThreadId())) {
throw new XATransactionException(XAException.XAER_PROTO, QueryPlugin.Util.getString("TransactionServer.wrong_transaction", xid)); //$NON-NLS-1$
}
} else if (tc.getThreadId() != null) {
throw new XATransactionException(XAException.XAER_PROTO, QueryPlugin.Util.getString("TransactionServer.concurrent_transaction", xid)); //$NON-NLS-1$
}
return tc;
}