* context for this thread.
* @param xaResourceHolder the {@link XAResourceHolder} to delist.
* @throws SystemException if an internal error happens.
*/
public static void delistFromCurrentTransaction(XAResourceHolder xaResourceHolder) throws SystemException {
final BitronixTransaction currentTransaction = currentTransaction();
ResourceBean bean = xaResourceHolder.getResourceBean();
if (log.isDebugEnabled()) { log.debug("delisting " + xaResourceHolder + " from " + currentTransaction); }
// End resource as eagerly as possible. This allows to release connections to the pool much earlier
// with resources fully supporting transaction interleaving.
if (isInEnlistingGlobalTransactionContext(xaResourceHolder, currentTransaction) && !bean.getDeferConnectionRelease()) {
class LocalVisitor implements XAResourceHolderStateVisitor {
private SystemException systemException = null;
public boolean visit(XAResourceHolderState xaResourceHolderState) {
if (!xaResourceHolderState.isEnded()) {
if (log.isDebugEnabled()) { log.debug("delisting resource " + xaResourceHolderState + " from " + currentTransaction); }
// Watch out: the delistResource() call might throw a BitronixRollbackSystemException to indicate a unilateral rollback.
try {
currentTransaction.delistResource(xaResourceHolderState.getXAResource(), XAResource.TMSUCCESS);
} catch (SystemException e) {
systemException = e;
return false; // stop visitation
}
}
else if (log.isDebugEnabled()) { log.debug("avoiding delistment of not enlisted resource " + xaResourceHolderState); }
return true; // continue visitation
}
};
LocalVisitor xaResourceHolderStateVisitor = new LocalVisitor();
xaResourceHolder.acceptVisitorForXAResourceHolderStates(currentTransaction.getResourceManager().getGtrid(), xaResourceHolderStateVisitor);
if (xaResourceHolderStateVisitor.systemException != null) {
throw xaResourceHolderStateVisitor.systemException;
}
} // isInEnlistingGlobalTransactionContext