Search in sources :

Example 1 with StatefulBMTInterceptor

use of org.jboss.as.ejb3.tx.StatefulBMTInterceptor in project wildfly by wildfly.

the class StatefulComponentDescription method createConfiguration.

@Override
public ComponentConfiguration createConfiguration(final ClassReflectionIndex classIndex, final ClassLoader moduleClassLoader, final ModuleLoader moduleLoader) {
    final ComponentConfiguration statefulComponentConfiguration = new ComponentConfiguration(this, classIndex, moduleClassLoader, moduleLoader);
    // setup the component create service
    statefulComponentConfiguration.setComponentCreateServiceFactory(new StatefulComponentCreateServiceFactory());
    if (getTransactionManagementType() == TransactionManagementType.BEAN) {
        getConfigurators().add(new ComponentConfigurator() {

            @Override
            public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
                final ComponentInstanceInterceptorFactory bmtComponentInterceptorFactory = new ComponentInstanceInterceptorFactory() {

                    @Override
                    protected Interceptor create(Component component, InterceptorFactoryContext context) {
                        if (!(component instanceof StatefulSessionComponent)) {
                            throw EjbLogger.ROOT_LOGGER.componentNotInstanceOfSessionComponent(component, component.getComponentClass(), "stateful");
                        }
                        return new StatefulBMTInterceptor((StatefulSessionComponent) component);
                    }
                };
                configuration.addComponentInterceptor(bmtComponentInterceptorFactory, InterceptorOrder.Component.BMT_TRANSACTION_INTERCEPTOR, false);
            }
        });
    } else {
        getConfigurators().add(new ComponentConfigurator() {

            @Override
            public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
                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(), false), InterceptorOrder.ComponentPostConstruct.TRANSACTION_INTERCEPTOR);
                configuration.addPreDestroyInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPreDestroy(), false), InterceptorOrder.ComponentPreDestroy.TRANSACTION_INTERCEPTOR);
                if (description.isPassivationApplicable()) {
                    configuration.addPrePassivateInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPrePassivate(), false), InterceptorOrder.ComponentPassivation.TRANSACTION_INTERCEPTOR);
                    configuration.addPostActivateInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPostActivate(), false), InterceptorOrder.ComponentPassivation.TRANSACTION_INTERCEPTOR);
                }
            }
        });
    }
    addStatefulSessionSynchronizationInterceptor();
    return statefulComponentConfiguration;
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ComponentInstanceInterceptorFactory(org.jboss.as.ee.component.ComponentInstanceInterceptorFactory) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) ComponentConfigurator(org.jboss.as.ee.component.ComponentConfigurator) ComponentTypeIdentityInterceptorFactory(org.jboss.as.ejb3.component.interceptors.ComponentTypeIdentityInterceptorFactory) InterceptorFactory(org.jboss.invocation.InterceptorFactory) ImmediateInterceptorFactory(org.jboss.invocation.ImmediateInterceptorFactory) ComponentInstanceInterceptorFactory(org.jboss.as.ee.component.ComponentInstanceInterceptorFactory) StatefulBMTInterceptor(org.jboss.as.ejb3.tx.StatefulBMTInterceptor) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) InterceptorFactoryContext(org.jboss.invocation.InterceptorFactoryContext) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) InterceptorClassDescription(org.jboss.as.ee.component.interceptors.InterceptorClassDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) Component(org.jboss.as.ee.component.Component) Interceptor(org.jboss.invocation.Interceptor) LifecycleCMTTxInterceptor(org.jboss.as.ejb3.tx.LifecycleCMTTxInterceptor) StatefulBMTInterceptor(org.jboss.as.ejb3.tx.StatefulBMTInterceptor)

Aggregations

Component (org.jboss.as.ee.component.Component)1 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)1 ComponentConfigurator (org.jboss.as.ee.component.ComponentConfigurator)1 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)1 ComponentInstanceInterceptorFactory (org.jboss.as.ee.component.ComponentInstanceInterceptorFactory)1 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)1 InterceptorClassDescription (org.jboss.as.ee.component.interceptors.InterceptorClassDescription)1 ComponentTypeIdentityInterceptorFactory (org.jboss.as.ejb3.component.interceptors.ComponentTypeIdentityInterceptorFactory)1 SessionBeanComponentDescription (org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)1 LifecycleCMTTxInterceptor (org.jboss.as.ejb3.tx.LifecycleCMTTxInterceptor)1 StatefulBMTInterceptor (org.jboss.as.ejb3.tx.StatefulBMTInterceptor)1 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)1 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)1 ImmediateInterceptorFactory (org.jboss.invocation.ImmediateInterceptorFactory)1 Interceptor (org.jboss.invocation.Interceptor)1 InterceptorFactory (org.jboss.invocation.InterceptorFactory)1 InterceptorFactoryContext (org.jboss.invocation.InterceptorFactoryContext)1