@ Override public void end ( Xid xid , int flags ) throws XAException { try { // not tested XS LOG . debug ( "PhynixxXAResource:end" ) ; LOG . debug ( "PhynixxXAResource[" + this . getId ( ) + "]:end xid='" + xid + "' flags='" + ConstantsPrinter . getXAResourceMessage ( flags ) + "'" ) ; if ( xid == null ) { LOG . error ( "No XID" ) ; throw new XAException ( XAException . XAER_INVAL ) ; } XATransactionalBranch < C > transactionalBranch = this . xaConnection . toGlobalTransactionBranch ( ) ; 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 ) ; } if ( flags == TMSUSPEND ) { this . xaConnection . suspendTransactionalBranch ( xid ) ; } else if ( flags == TMSUCCESS ) { // XAProtocol is finsihed an the branch isn't needed any longer if ( transactionalBranch . isXAProtocolFinished ( ) ) { transactionalBranch . close ( ) ; LOG . debug ( "XAResource " + this + " closed gracefully " ) ; } } else if ( flags == TMFAIL ) { transactionalBranch . setRollbackOnly ( true ) ; } } catch ( XAException xaExc ) { LOG . error ( "PhynixxXAResource[" + this . getId ( ) + "]:end xid='" + xid + "' flags='" + ConstantsPrinter . getXAResourceMessage ( flags ) + "'" + " ERROR " + ConstantsPrinter . getXAErrorCode ( xaExc . errorCode ) ) ; throw xaExc ; } catch ( Exception ex ) { LOG . error ( "PhynixxXAResource.end(" + xid + "," + flags + ") on XAResourceProgressState " + this . xaId + " :: " + ex + "\n" + ExceptionUtils . getStackTrace ( ex ) ) ; throw new DelegatedRuntimeException ( "end(" + xid + "," + flags + ") on XAResourceProgressState " + this . xaId , ex ) ; } }
This method ends the work performed on behalf of a transaction branch .