// Register our listeners on SFSB that will be created
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 {
final SFSBXPCMap map = SFSBXPCMap.getXpcMap(deploymentUnit);
configuration.addPostConstructInterceptor(SFSBPreCreateInterceptor.FACTORY, InterceptorOrder.ComponentPostConstruct.JPA_SFSB_PRE_CREATE);
configuration.addPostConstructInterceptor(new SFSBCreateInterceptor.Factory(map), InterceptorOrder.ComponentPostConstruct.JPA_SFSB_CREATE);
configuration.addPreDestroyInterceptor(new SFSBDestroyInterceptor.Factory(map), InterceptorOrder.ComponentPreDestroy.JPA_SFSB_DESTROY);
}
});
Iterable<ViewDescription> views = componentDescription.getViews();
for (ViewDescription view : views) {
view.getConfigurators().addFirst(new ViewConfigurator() {
@Override
public void configure(DeploymentPhaseContext context, ComponentConfiguration componentConfiguration, ViewDescription description, ViewConfiguration configuration) throws
DeploymentUnitProcessingException {
configuration.addViewInterceptor(SFSBInvocationInterceptor.FACTORY, InterceptorOrder.View.JPA_SFSB_INTERCEPTOR);
}
});
}
}
// 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);
if(description.isTimerServiceApplicable()) {