protected void startRes ( JTAResource resource ) throws RollbackException , SystemException { if ( tc . isEntryEnabled ( ) ) Tr . entry ( tc , "startRes" , new Object [ ] { this , resource } ) ; try { resource . start ( ) ; } catch ( XAException xae ) { _errorCode = xae . errorCode ; // Save locally for FFDC FFDCFilter . processException ( xae , "com.ibm.tx.jta.impl.RegisteredResources.startRes" , "1053" , this ) ; if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "XAException: error code " + XAReturnCodeHelper . convertXACode ( _errorCode ) , xae ) ; final Throwable toThrow ; // // the XAResource object is doing work outside global // transaction. This means that XAResource is doing local // transaction. Local transaction has to be completed before // start global transaction or XA transaction. // if ( _errorCode == XAException . XAER_OUTSIDE ) { toThrow = new RollbackException ( "XAResource working outside transaction" ) . initCause ( xae ) ; if ( tc . isEventEnabled ( ) ) Tr . event ( tc , "XAResource is doing work outside of the transaction." , toThrow ) ; throw ( RollbackException ) toThrow ; } else if ( _errorCode >= XAException . XA_RBBASE && _errorCode <= XAException . XA_RBEND ) { if ( tc . isEventEnabled ( ) ) Tr . event ( tc , "Transaction branch has been marked rollback-only by the RM" ) ; // // Transaction branch has been rolled back, so we // mark transaction as rollback only. // try { _transaction . setRollbackOnly ( ) ; } catch ( IllegalStateException e ) { FFDCFilter . processException ( e , "com.ibm.tx.jta.impl.RegisteredResources.startRes" , "1085" , this ) ; if ( tc . isEventEnabled ( ) ) Tr . event ( tc , "Exception caught marking Transaction rollback only" , e ) ; throw ( SystemException ) new SystemException ( e . getLocalizedMessage ( ) ) . initCause ( e ) ; } toThrow = new RollbackException ( "Transaction has been marked as rollback only." ) . initCause ( xae ) ; if ( tc . isEventEnabled ( ) ) Tr . event ( tc , "Marked transaction as rollback only." , toThrow ) ; throw ( RollbackException ) toThrow ; } // // Any other error is a protocol violation or the RM is broken, and we throw // SystemException. // else // XAER_RMERR, XAER_RMFAIL, XAER_INVAL, XAER_PROTO, XAER_DUPID { Tr . error ( tc , "WTRN0078_START_FAILED" , new Object [ ] { XAReturnCodeHelper . convertXACode ( _errorCode ) , xae } ) ; throw ( SystemException ) new SystemException ( "XAResource start association error:" + XAReturnCodeHelper . convertXACode ( _errorCode ) ) . initCause ( xae ) ; } } finally { if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "startRes" ) ; } }
Starts association of the resource with the current transaction and if required adds a reference to a Resource object to the list in the registered state .