final XAResource enlistRRSXAResource ( int recoveryId , int branchCoupling ) throws Exception { RRSXAResourceFactory xaFactory = ( RRSXAResourceFactory ) pm . connectorSvc . rrsXAResFactorySvcRef . getService ( ) ; // Make sure that the bundle is active. if ( xaFactory == null ) { throw new IllegalStateException ( "Native service for RRS transactional support is not active or available. Resource enlistment is rejected." ) ; } XAResource xaResource = null ; UOWCurrent currentUOW = ( UOWCurrent ) pm . connectorSvc . transactionManager ; UOWCoordinator uowCoord = currentUOW . getUOWCoord ( ) ; // Enlist XA resource. if ( uowCoord . isGlobal ( ) ) { // Enlist a 2 phase XA resource in the global transaction. xaResource = xaFactory . getTwoPhaseXAResource ( uowCoord . getXid ( ) ) ; pm . connectorSvc . transactionManager . enlist ( uowCoord , xaResource , recoveryId , branchCoupling ) ; } else { // Enlist a one phase XA resource in the local transaction. If enlisting for // cleanup, notify the factory that the resource has been enlisted for cleanup // with the transaction manager. xaResource = xaFactory . getOnePhaseXAResource ( uowCoord ) ; LocalTransactionCoordinator ltCoord = ( LocalTransactionCoordinator ) uowCoord ; if ( ltCoord . isContainerResolved ( ) ) { ltCoord . enlist ( ( OnePhaseXAResource ) xaResource ) ; } else { ltCoord . enlistForCleanup ( ( OnePhaseXAResource ) xaResource ) ; } // Enlist with the native transaction manager (factory). xaFactory . enlist ( uowCoord , xaResource ) ; } return xaResource ; }
Enlists a RRS XA resource with the transaction manager .