if (flag != XAResource.TMSUCCESS && flag != XAResource.TMSUSPEND && flag != XAResource.TMFAIL)
throw new BitronixSystemException("can only delist with SUCCESS, SUSPEND, FAIL - was: " + Decoder.decodeXAResourceFlag(flag));
if (isWorking())
throw new IllegalStateException("transaction is being committed or rolled back, cannot delist any resource now");
XAResourceHolder resourceHolder = ResourceRegistrar.findXAResourceHolder(xaResource);
if (resourceHolder == null)
throw new BitronixSystemException("unknown XAResource " + xaResource + ", it does not belong to a registered resource");
class LocalVisitor implements XAResourceHolderStateVisitor {
private boolean result = true;
private List<BitronixSystemException> exceptions = new ArrayList<BitronixSystemException>();
private List<XAResourceHolderState> resourceStates = new ArrayList<XAResourceHolderState>();
public boolean visit(XAResourceHolderState xaResourceHolderState) {
try {
result &= delistResource(xaResourceHolderState, flag);
} catch (BitronixSystemException ex) {
if (log.isDebugEnabled()) { log.debug("failed to delist resource state " + xaResourceHolderState); }
exceptions.add(ex);
resourceStates.add(xaResourceHolderState);
}
return true; // continue visitation
}
}
LocalVisitor xaResourceHolderStateVisitor = new LocalVisitor();
resourceHolder.acceptVisitorForXAResourceHolderStates(resourceManager.getGtrid(), xaResourceHolderStateVisitor);
if (!xaResourceHolderStateVisitor.exceptions.isEmpty()) {
BitronixMultiSystemException multiSystemException = new BitronixMultiSystemException("error delisting resource", xaResourceHolderStateVisitor.exceptions, xaResourceHolderStateVisitor.resourceStates);
if (!multiSystemException.isUnilateralRollback()) {
throw multiSystemException;