public static void passivateProfileObjectOnTxEnd ( SleeTransactionManager txManager , final ProfileObjectImpl profileObject , final ProfileObjectPool pool ) { TransactionalAction afterRollbackAction = new TransactionalAction ( ) { public void execute ( ) { profileObject . invalidateObject ( ) ; pool . returnObject ( profileObject ) ; } } ; TransactionalAction beforeCommitAction = new TransactionalAction ( ) { public void execute ( ) { if ( profileObject . getState ( ) == ProfileObjectState . READY ) { if ( ! profileObject . getProfileEntity ( ) . isRemove ( ) ) { profileObject . fireAddOrUpdatedEventIfNeeded ( ) ; profileObject . profilePassivate ( ) ; } else { profileObject . profileRemove ( true , false ) ; } pool . returnObject ( profileObject ) ; } } } ; final TransactionContext txContext = txManager . getTransactionContext ( ) ; txContext . getAfterRollbackActions ( ) . add ( afterRollbackAction ) ; txContext . getBeforeCommitActions ( ) . add ( beforeCommitAction ) ; }
Adds transactional actions to the active transaction to passivate a profile object .