public void registerInterposedSynchronization ( Synchronization synchronization ) throws IllegalStateException , SystemException { int status = ContextTransactionSynchronizationRegistry . getInstance ( ) . getTransactionStatus ( ) ; switch ( status ) { case javax . transaction . Status . STATUS_ACTIVE : case javax . transaction . Status . STATUS_PREPARING : break ; case Status . STATUS_MARKED_ROLLBACK : // do nothing; we can pretend like it was registered, but it'll never be run anyway. return ; default : throw TransactionLogger . ROOT_LOGGER . syncsnotallowed ( status ) ; } if ( synchronization . getClass ( ) . getName ( ) . startsWith ( "org.jboss.jca" ) ) { if ( TransactionLogger . ROOT_LOGGER . isTraceEnabled ( ) ) { TransactionLogger . ROOT_LOGGER . trace ( "JCAOrderedLastSynchronizationList.jcaSyncs.add - Class: " + synchronization . getClass ( ) + " HashCode: " + synchronization . hashCode ( ) + " toString: " + synchronization ) ; } jcaSyncs . add ( synchronization ) ; } else { if ( TransactionLogger . ROOT_LOGGER . isTraceEnabled ( ) ) { TransactionLogger . ROOT_LOGGER . trace ( "JCAOrderedLastSynchronizationList.preJcaSyncs.add - Class: " + synchronization . getClass ( ) + " HashCode: " + synchronization . hashCode ( ) + " toString: " + synchronization ) ; } preJcaSyncs . add ( synchronization ) ; } }
This is only allowed at various points of the transaction lifecycle .