question: public synchronized void notifyBeforeUse ( CompositeTransaction ct ) throws InvalidSessionHandleStateException { if ( closed ) throw new InvalidSessionHandleStateException ( "The underlying XA session is closed" ) ; try { TransactionContext suspended = null ; if ( ct != null ) { Iterator < TransactionContext > it = allContexts . iterator ( ) ; while ( it . hasNext ( ) && suspended == null ) { TransactionContext b = ( TransactionContext ) it . next ( ) ; if ( b . isSuspendedInTransaction ( ct ) ) { suspended = b ; } } } if ( suspended != null ) { if ( LOGGER . isDebugEnabled ( ) ) LOGGER . logDebug ( this + ": resuming suspended XA context for transaction " + ct . getTid ( ) ) ; currentContext = suspended ; currentContext . transactionResumed ( ) ; } else { try { if ( LOGGER . isTraceEnabled ( ) ) LOGGER . logTrace ( this + ": checking XA context for transaction " + ct ) ; currentContext . checkEnlistBeforeUse ( ct ) ; } catch ( UnexpectedTransactionContextException txBoundaryPassed ) { if ( LOGGER . isDebugEnabled ( ) ) LOGGER . logDebug ( this + ": suspending existing XA context and creating a new one for transaction " + ct ) ; currentContext . transactionSuspended ( ) ; currentContext = new TransactionContext ( resource , xaResource ) ; allContexts . add ( currentContext ) ; try { currentContext . checkEnlistBeforeUse ( ct ) ; } catch ( UnexpectedTransactionContextException e ) { String msg = "Unexpected error in session handle" ; LOGGER . logError ( msg , e ) ; throw new InvalidSessionHandleStateException ( msg ) ; } } } } catch ( InvalidSessionHandleStateException e ) { notifySessionErrorOccurred ( ) ; throw e ; } }
target:  Notification that the session handle is about to be used in the current transaction context (i.e. whatever transaction exists for the calling thread).  This method MUST be called BEFORE any work is delegated to the underlying vendor connection.