@ Override public int prepare ( Xid xid ) throws XAException { try { LOG . debug ( "PhynixxXAResource[" + this . getId ( ) + "]:prepare prepare to perform a commit for XID=" + xid ) ; XATransactionalBranch < C > transactionalBranch = this . xaConnection . toGlobalTransactionBranch ( ) ; if ( xid == null ) { LOG . error ( "No XID" ) ; throw new XAException ( XAException . XAER_INVAL ) ; } if ( transactionalBranch == null ) { LOG . error ( "XAConnection is not associated to a global Transaction" ) ; throw new XAException ( XAException . XAER_PROTO ) ; } // assert that the current xaConnection is associated to this XID if ( ! transactionalBranch . getXid ( ) . equals ( xid ) ) { LOG . error ( "XAResource " + this + " isnt't active for XID=" + xid ) ; throw new XAException ( XAException . XAER_PROTO ) ; } // must find connection for this transaction int retVal = transactionalBranch . prepare ( ) ; if ( retVal == XAResource . XA_RDONLY ) { this . xaConnection . closeTransactionalBranch ( xid ) ; } return retVal ; } catch ( XAException xaExc ) { LOG . error ( "PhynixxXAResource[" + this . getId ( ) + "]:prepare xid='" + xid + " ERROR " + ConstantsPrinter . getXAErrorCode ( xaExc . errorCode ) ) ; throw xaExc ; } catch ( Exception ex ) { LOG . error ( "PhynixxXAResource.prepare(" + xid + ") on XAResourceProgressState " + this . xaId + " :: " + ex + "\n" + ExceptionUtils . getStackTrace ( ex ) ) ; throw new DelegatedRuntimeException ( "prepare(" + xid + ") on XAResourceProgressState " + this . xaId , ex ) ; } }
finds the transactional branch of the current XAResource associated with die XID