public boolean enlistResource ( XAResource xaRes ) throws RollbackException , SystemException , IllegalStateException { if ( tc . isEntryEnabled ( ) ) Tr . entry ( tc , "enlistResource" , xaRes ) ; // Determine if we are attempting to enlist a second resource within a transaction // that can't support 2PC anyway. if ( _disableTwoPhase && ( _resourceObjects . size ( ) > 0 ) ) { final String msg = "Unable to enlist a second resource within the transaction. Two phase support is disabled " + "as the recovery log was not available at transaction start" ; final IllegalStateException ise = new IllegalStateException ( msg ) ; if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "enlistResource (SPI)" , ise ) ; throw ise ; } // Create the resource wrapper and see if it already exists in the table OnePhaseResourceImpl jtaRes = new OnePhaseResourceImpl ( ( OnePhaseXAResource ) xaRes , _txServiceXid ) ; boolean register = true ; // See if any other resource has been enlisted // Allow 1PC and 2PC to be enlisted, it will be rejected at prepare time if LPS is not enabled // Reject multiple 1PC enlistments if ( _onePhaseResourceEnlisted != null ) { if ( _onePhaseResourceEnlisted . equals ( jtaRes ) ) { register = false ; jtaRes = _onePhaseResourceEnlisted ; } else { Tr . error ( tc , "WTRN0062_ILLEGAL_ENLIST_FOR_MULTIPLE_1PC_RESOURCES" ) ; final String msg = "Illegal attempt to enlist multiple 1PC XAResources" ; final IllegalStateException ise = new IllegalStateException ( msg ) ; // FFDC in TransactionImpl if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "enlistResource (SPI)" , ise ) ; throw ise ; } } // // start association of Resource object and register if first time with JTA // and record that a 1PC resource has now been registered with the transaction. // try { this . startRes ( jtaRes ) ; if ( register ) { jtaRes . setResourceStatus ( StatefulResource . REGISTERED ) ; // This is 1PC then we need to insert at element 0 // of the list so we can ensure it is processed last // at completion time. _resourceObjects . add ( 0 , jtaRes ) ; // Check and update LPS enablement state for the application - LIDB1673.22 checkLPSEnablement ( ) ; if ( tc . isEventEnabled ( ) ) Tr . event ( tc , "(SPI) RESOURCE registered with Transaction. TX: " + _transaction . getLocalTID ( ) + ", Resource: " + jtaRes ) ; _onePhaseResourceEnlisted = jtaRes ; } } catch ( RollbackException rbe ) { FFDCFilter . processException ( rbe , "com.ibm.tx.jta.impl.RegisteredResources.enlistResource" , "480" , this ) ; if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "enlistResource" , rbe ) ; throw rbe ; } catch ( SystemException se ) { FFDCFilter . processException ( se , "com.ibm.tx.jta.impl.RegisteredResources.enlistResource" , "487" , this ) ; if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "enlistResource" , se ) ; throw se ; } if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "enlistResource" , Boolean . TRUE ) ; return true ; }
Attempts to add a one - Phase XA Resource to this unit of work .