private void registerSessionBeanInterceptors ( SessionBeanComponentDescription componentDescription , final DeploymentUnit deploymentUnit ) { // if it's a SFSB then setup appropriate interceptors if ( componentDescription . isStateful ( ) ) { // first setup the post construct and pre destroy component interceptors componentDescription . getConfigurators ( ) . addFirst ( new ComponentConfigurator ( ) { @ Override public void configure ( DeploymentPhaseContext context , ComponentDescription description , ComponentConfiguration configuration ) throws DeploymentUnitProcessingException { configuration . addPostConstructInterceptor ( SFSBPreCreateInterceptor . FACTORY , InterceptorOrder . ComponentPostConstruct . JPA_SFSB_PRE_CREATE ) ; configuration . addPostConstructInterceptor ( SFSBCreateInterceptor . FACTORY , InterceptorOrder . ComponentPostConstruct . JPA_SFSB_CREATE ) ; configuration . addPreDestroyInterceptor ( SFSBDestroyInterceptor . FACTORY , InterceptorOrder . ComponentPreDestroy . JPA_SFSB_DESTROY ) ; configuration . addComponentInterceptor ( SFSBInvocationInterceptor . FACTORY , InterceptorOrder . Component . JPA_SFSB_INTERCEPTOR , false ) ; //we need to serialized the entity manager state configuration . getInterceptorContextKeys ( ) . add ( SFSBInvocationInterceptor . CONTEXT_KEY ) ; } } ) ; } // register interceptor on stateful/stateless SB with transactional entity manager. if ( ( componentDescription . isStateful ( ) || componentDescription . isStateless ( ) ) ) { componentDescription . getConfigurators ( ) . add ( new ComponentConfigurator ( ) { @ Override public void configure ( DeploymentPhaseContext context , ComponentDescription description , ComponentConfiguration configuration ) throws DeploymentUnitProcessingException { configuration . addComponentInterceptor ( SBInvocationInterceptor . FACTORY , InterceptorOrder . Component . JPA_SESSION_BEAN_INTERCEPTOR , false ) ; } } ) ; } }
Register our listeners on SFSB that will be created