@Override public ComponentConfiguration createConfiguration( final ClassIndex classIndex, final ClassLoader moduleClassLoder) { final ComponentConfiguration statelessComponentConfiguration = new ComponentConfiguration(this, classIndex, moduleClassLoder); // setup the component create service statelessComponentConfiguration.setComponentCreateServiceFactory( new StatelessComponentCreateServiceFactory()); // setup the configurator to inject the PoolConfig in the StatelessSessionComponentCreateService final StatelessComponentDescription statelessComponentDescription = (StatelessComponentDescription) statelessComponentConfiguration.getComponentDescription(); statelessComponentConfiguration .getCreateDependencies() .add(new PoolInjectingConfigurator(statelessComponentDescription)); // add the bmt interceptor if (TransactionManagementType.BEAN.equals(this.getTransactionManagementType())) { getConfigurators() .add( new ComponentConfigurator() { @Override public void configure( final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException { final ComponentInstanceInterceptorFactory slsbBmtInterceptorFactory = new ComponentInstanceInterceptorFactory() { @Override protected Interceptor create( Component component, InterceptorFactoryContext context) { if (!(component instanceof StatelessSessionComponent)) { throw MESSAGES.componentNotInstanceOfSessionComponent( component, component.getComponentClass(), "stateless"); } return new StatelessBMTInterceptor((StatelessSessionComponent) component); } }; // add the bmt interceptor factory configuration.addComponentInterceptor( slsbBmtInterceptorFactory, InterceptorOrder.Component.BMT_TRANSACTION_INTERCEPTOR, false); configuration.addTimeoutInterceptor( slsbBmtInterceptorFactory, InterceptorOrder.Component.BMT_TRANSACTION_INTERCEPTOR); } }); } else { getConfigurators() .add( new ComponentConfigurator() { @Override public void configure( final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException { configuration.addTimeoutInterceptor( TimerCMTTxInterceptor.FACTORY, InterceptorOrder.Component.TIMEOUT_CMT_INTERCEPTOR); } }); } return statelessComponentConfiguration; }
@Override public ComponentConfiguration createConfiguration( final ClassIndex classIndex, final ClassLoader moduleClassLoader, final ModuleLoader moduleLoader) { final ComponentConfiguration statelessComponentConfiguration = new ComponentConfiguration(this, classIndex, moduleClassLoader, moduleLoader); // setup the component create service statelessComponentConfiguration.setComponentCreateServiceFactory( new StatelessComponentCreateServiceFactory()); // setup the configurator to inject the PoolConfig in the StatelessSessionComponentCreateService final StatelessComponentDescription statelessComponentDescription = (StatelessComponentDescription) statelessComponentConfiguration.getComponentDescription(); statelessComponentConfiguration .getCreateDependencies() .add(new PoolInjectingConfigurator(statelessComponentDescription)); // add the bmt interceptor if (TransactionManagementType.BEAN.equals(this.getTransactionManagementType())) { getConfigurators() .add( new ComponentConfigurator() { @Override public void configure( final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException { // add the bmt interceptor factory configuration.addComponentInterceptor( EjbBMTInterceptor.FACTORY, InterceptorOrder.Component.BMT_TRANSACTION_INTERCEPTOR, false); } }); } getConfigurators() .add( new ComponentConfigurator() { @Override public void configure( final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException { if (TransactionManagementType.CONTAINER.equals(getTransactionManagementType())) { final EEApplicationClasses applicationClasses = context .getDeploymentUnit() .getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION); InterceptorClassDescription interceptorConfig = ComponentDescription.mergeInterceptorConfig( configuration.getComponentClass(), applicationClasses.getClassByName(description.getComponentClassName()), description, MetadataCompleteMarker.isMetadataComplete(context.getDeploymentUnit())); configuration.addPostConstructInterceptor( new LifecycleCMTTxInterceptor.Factory( interceptorConfig.getPostConstruct(), true), InterceptorOrder.ComponentPostConstruct.TRANSACTION_INTERCEPTOR); configuration.addPreDestroyInterceptor( new LifecycleCMTTxInterceptor.Factory( interceptorConfig.getPreDestroy(), true), InterceptorOrder.ComponentPreDestroy.TRANSACTION_INTERCEPTOR); configuration.addTimeoutViewInterceptor( TimerCMTTxInterceptor.FACTORY, InterceptorOrder.View.CMT_TRANSACTION_INTERCEPTOR); } configuration.addTimeoutViewInterceptor( StatelessComponentInstanceAssociatingFactory.instance(), InterceptorOrder.View.ASSOCIATING_INTERCEPTOR); } }); return statelessComponentConfiguration; }