@ Override public boolean addSync ( ) throws ResourceException { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) { Tr . entry ( this , tc , "addSync" ) ; } UOWCoordinator uowCoord = mcWrapper . getUOWCoordinator ( ) ; if ( uowCoord == null ) { // No transaction context. Should never happen. // removed null check on mcWrapper since it is redundant from the above code (mcWrapper.getUOWCoordinator()) String pmiName = mcWrapper . gConfigProps . cfName ; Object [ ] parms = new Object [ ] { "addSync" , pmiName } ; Tr . error ( tc , "NO_VALID_TRANSACTION_CONTEXT_J2CA0040" , parms ) ; throw new ResourceException ( "INTERNAL ERROR: No valid transaction context present" ) ; } try { // No need to register for synchronization for unshared/LTC/res-control=Application. // Instead of cleanup being done via after completion it will either happen at close or // commit/rollback which ever happens last. This will allow the connection to be returned // to the pool prior to the end of the LTC scope allowing better utilization of the connection. boolean shareable = mcWrapper . getConnectionManager ( ) . shareable ( ) ; if ( ! shareable && ! J2CUtilityClass . isContainerAtBoundary ( mcWrapper . pm . connectorSvc . transactionManager ) ) { //Register an instance of a no-transaction wrapper // so the TM will create an RRS NativeLocalTranasction. The wrapper // provides "empty" TransactioWrapper and Synchronization behaviors, // but indicates to the TM that the LTC requires RRS support. ( ( LocalTransactionCoordinator ) uowCoord ) . enlistSynchronization ( new RRSNoTransactionWrapper ( ) ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) { Tr . exit ( this , tc , "addSync" , "returning without registering." ) ; } return false ; } else { // Register a synchronization with the Transaction Manager ( ( LocalTransactionCoordinator ) uowCoord ) . enlistSynchronization ( this ) ; mcWrapper . markRRSLocalTransactionWrapperInUse ( ) ; registeredForSync = true ; } } catch ( ResourceException e ) { com . ibm . ws . ffdc . FFDCFilter . processException ( e , "com.ibm.ejs.j2c.RRSLocalTransactionWrapper.addSync" , "594" , this ) ; Object [ ] parms = new Object [ ] { "addSync" , e , "Exception" } ; Tr . error ( tc , "REGISTER_WITH_SYNCHRONIZATION_EXCP_J2CA0026" , parms ) ; throw e ; } catch ( Exception e ) { com . ibm . ws . ffdc . FFDCFilter . processException ( e , "com.ibm.ejs.j2c.RRSLocalTransactionWrapper.addSync" , "605" , this ) ; Object [ ] parms = new Object [ ] { "addSync" , e , "Exception" } ; Tr . error ( tc , "REGISTER_WITH_SYNCHRONIZATION_EXCP_J2CA0026" , parms ) ; ResourceException re = new ResourceException ( "addSync: caught Exception" ) ; re . initCause ( e ) ; throw re ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) { Tr . exit ( this , tc , "addSync" , registeredForSync ) ; } return registeredForSync ; }
Register the RRSLocalTransactionWrapper as a sync object with the Transaction Manager for the current transaction .