public boolean canEnrollChangeToGlobalTx ( final SessionImpl session , final PlainChangesLog changes ) { try { int status ; if ( tm != null && ( status = tm . getStatus ( ) ) != Status . STATUS_NO_TRANSACTION ) { if ( status != Status . STATUS_ACTIVE && status != Status . STATUS_PREPARING ) { throw new IllegalStateException ( "The session cannot be enrolled in the current global transaction due " + "to an invalidate state, the current status is " + status + " and only ACTIVE and PREPARING are allowed" ) ; } SecurityHelper . doPrivilegedExceptionAction ( new PrivilegedExceptionAction < Void > ( ) { public Void run ( ) throws Exception { add ( session , changes ) ; return null ; } } ) ; return true ; } } catch ( PrivilegedActionException e ) { log . warn ( "Could not check if a global Tx has been started or register the session into the resource manager" , e ) ; } catch ( SystemException e ) { log . warn ( "Could not check if a global Tx has been started or register the session into the resource manager" , e ) ; } return false ; }
Checks if a global Tx has been started if so the session and its change will be dynamically enrolled