XAResourceHolder resourceHolder = ResourceRegistrar.findXAResourceHolder(xaResource);
if (resourceHolder == null)
throw new BitronixSystemException("unknown XAResource " + xaResource + ", it does not belong to a registered resource");
XAResourceHolderState resourceHolderState = new XAResourceHolderState(resourceHolder, resourceHolder.getResourceBean());
// resource timeout must be set here so manually enlisted resources can receive it
resourceHolderState.setTransactionTimeoutDate(timeoutDate);
try {
resourceManager.enlist(resourceHolderState);
} catch (XAException ex) {
String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(ex);
if (BitronixXAException.isUnilateralRollback(ex)) {
// if the resource unilaterally rolled back, the transaction will never be able to commit -> mark it as rollback only
setStatus(Status.STATUS_MARKED_ROLLBACK);
throw new BitronixRollbackException("resource " + resourceHolderState + " unilaterally rolled back, error=" +
Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex);
}
throw new BitronixSystemException("cannot enlist " + resourceHolderState + ", error=" +
Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex);
}
resourceHolder.putXAResourceHolderState(resourceHolderState.getXid(), resourceHolderState);
return true;
}