Search in sources :

Example 6 with InterceptorClassDescription

use of org.jboss.as.ee.component.interceptors.InterceptorClassDescription in project wildfly by wildfly.

the class SingletonComponentDescription method createConfiguration.

@Override
public ComponentConfiguration createConfiguration(final ClassReflectionIndex classIndex, final ClassLoader moduleClassLoader, final ModuleLoader moduleLoader) {
    ComponentConfiguration singletonComponentConfiguration = new ComponentConfiguration(this, classIndex, moduleClassLoader, moduleLoader);
    // setup the component create service
    singletonComponentConfiguration.setComponentCreateServiceFactory(new SingletonComponentCreateServiceFactory(this.isInitOnStartup(), dependsOn));
    if (isExplicitSecurityDomainConfigured()) {
        getConfigurators().add(new ComponentConfigurator() {

            @Override
            public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
                final DeploymentUnit deploymentUnit = context.getDeploymentUnit();
                String contextID = deploymentUnit.getName();
                if (deploymentUnit.getParent() != null) {
                    contextID = deploymentUnit.getParent().getName() + "!" + contextID;
                }
                EJBComponentDescription ejbComponentDescription = (EJBComponentDescription) description;
                if (isSecurityDomainKnown()) {
                    final HashMap<Integer, InterceptorFactory> elytronInterceptorFactories = getElytronInterceptorFactories(contextID, ejbComponentDescription.isEnableJacc());
                    elytronInterceptorFactories.forEach((priority, elytronInterceptorFactory) -> configuration.addPostConstructInterceptor(elytronInterceptorFactory, priority));
                } else {
                    configuration.addPostConstructInterceptor(new SecurityContextInterceptorFactory(isExplicitSecurityDomainConfigured(), false, contextID), InterceptorOrder.View.SECURITY_CONTEXT);
                }
            }
        });
    }
    getConfigurators().add(new ComponentConfigurator() {

        @Override
        public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
            if (isInitOnStartup()) {
                final StartupCountdown startupCountdown = context.getDeploymentUnit().getAttachment(Attachments.STARTUP_COUNTDOWN);
                configuration.addPostConstructInterceptor(new ImmediateInterceptorFactory(new StartupCountDownInterceptor(startupCountdown)), InterceptorOrder.ComponentPostConstruct.STARTUP_COUNTDOWN_INTERCEPTOR);
            }
        }
    });
    if (getTransactionManagementType().equals(TransactionManagementType.CONTAINER)) {
        //we need to add the transaction interceptor to the lifecycle methods
        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()));
                if (interceptorConfig.getPostConstruct() != null) {
                    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);
            }
        });
    } else {
        // add the bmt interceptor
        getConfigurators().add(new ComponentConfigurator() {

            @Override
            public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
                configuration.addPostConstructInterceptor(EjbBMTInterceptor.FACTORY, InterceptorOrder.ComponentPostConstruct.TRANSACTION_INTERCEPTOR);
                configuration.addPreDestroyInterceptor(EjbBMTInterceptor.FACTORY, InterceptorOrder.ComponentPreDestroy.TRANSACTION_INTERCEPTOR);
                // add the bmt interceptor factory
                configuration.addComponentInterceptor(EjbBMTInterceptor.FACTORY, InterceptorOrder.Component.BMT_TRANSACTION_INTERCEPTOR, false);
            }
        });
    }
    return singletonComponentConfiguration;
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) InterceptorClassDescription(org.jboss.as.ee.component.interceptors.InterceptorClassDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) ComponentTypeIdentityInterceptorFactory(org.jboss.as.ejb3.component.interceptors.ComponentTypeIdentityInterceptorFactory) ClassReflectionIndex(org.jboss.as.server.deployment.reflect.ClassReflectionIndex) InterceptorFactory(org.jboss.invocation.InterceptorFactory) ConcurrencyManagementType(javax.ejb.ConcurrencyManagementType) SessionBeanMetaData(org.jboss.metadata.ejb.spec.SessionBeanMetaData) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) LifecycleCMTTxInterceptor(org.jboss.as.ejb3.tx.LifecycleCMTTxInterceptor) HashMap(java.util.HashMap) WriteReplaceInterface(org.jboss.as.ee.component.serialization.WriteReplaceInterface) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) StatelessWriteReplaceInterceptor(org.jboss.as.ejb3.component.session.StatelessWriteReplaceInterceptor) ArrayList(java.util.ArrayList) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) InterceptorOrder(org.jboss.as.ee.component.interceptors.InterceptorOrder) ImmediateInterceptorFactory(org.jboss.invocation.ImmediateInterceptorFactory) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex) Method(java.lang.reflect.Method) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) EjbJarDescription(org.jboss.as.ejb3.deployment.EjbJarDescription) MethodIntf(org.jboss.as.ejb3.component.MethodIntf) ModuleLoader(org.jboss.modules.ModuleLoader) MetadataCompleteMarker(org.jboss.as.ee.metadata.MetadataCompleteMarker) ViewConfigurator(org.jboss.as.ee.component.ViewConfigurator) ContainerManagedConcurrencyInterceptorFactory(org.jboss.as.ejb3.concurrency.ContainerManagedConcurrencyInterceptorFactory) StartupCountdown(org.jboss.as.ee.component.deployers.StartupCountdown) StatelessRemoteViewInstanceFactory(org.jboss.as.ejb3.component.session.StatelessRemoteViewInstanceFactory) SecurityContextInterceptorFactory(org.jboss.as.ejb3.security.SecurityContextInterceptorFactory) TimerCMTTxInterceptor(org.jboss.as.ejb3.tx.TimerCMTTxInterceptor) EjbBMTInterceptor(org.jboss.as.ejb3.tx.EjbBMTInterceptor) Attachments(org.jboss.as.ee.component.Attachments) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) List(java.util.List) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) ComponentConfigurator(org.jboss.as.ee.component.ComponentConfigurator) ViewConfiguration(org.jboss.as.ee.component.ViewConfiguration) EjbLogger(org.jboss.as.ejb3.logging.EjbLogger) ServiceName(org.jboss.msc.service.ServiceName) ViewDescription(org.jboss.as.ee.component.ViewDescription) Collections(java.util.Collections) TransactionManagementType(javax.ejb.TransactionManagementType) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) ComponentConfigurator(org.jboss.as.ee.component.ComponentConfigurator) HashMap(java.util.HashMap) ComponentTypeIdentityInterceptorFactory(org.jboss.as.ejb3.component.interceptors.ComponentTypeIdentityInterceptorFactory) InterceptorFactory(org.jboss.invocation.InterceptorFactory) ImmediateInterceptorFactory(org.jboss.invocation.ImmediateInterceptorFactory) ContainerManagedConcurrencyInterceptorFactory(org.jboss.as.ejb3.concurrency.ContainerManagedConcurrencyInterceptorFactory) StatelessRemoteViewInstanceFactory(org.jboss.as.ejb3.component.session.StatelessRemoteViewInstanceFactory) SecurityContextInterceptorFactory(org.jboss.as.ejb3.security.SecurityContextInterceptorFactory) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) InterceptorClassDescription(org.jboss.as.ee.component.interceptors.InterceptorClassDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) SecurityContextInterceptorFactory(org.jboss.as.ejb3.security.SecurityContextInterceptorFactory) ImmediateInterceptorFactory(org.jboss.invocation.ImmediateInterceptorFactory) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) StartupCountdown(org.jboss.as.ee.component.deployers.StartupCountdown)

Aggregations

InterceptorClassDescription (org.jboss.as.ee.component.interceptors.InterceptorClassDescription)6 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)6 ImmediateInterceptorFactory (org.jboss.invocation.ImmediateInterceptorFactory)5 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)4 ComponentConfigurator (org.jboss.as.ee.component.ComponentConfigurator)4 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)4 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)4 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)4 InterceptorFactory (org.jboss.invocation.InterceptorFactory)4 Method (java.lang.reflect.Method)3 ArrayList (java.util.ArrayList)3 ComponentTypeIdentityInterceptorFactory (org.jboss.as.ejb3.component.interceptors.ComponentTypeIdentityInterceptorFactory)3 SessionBeanComponentDescription (org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)3 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)3 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)3 ArrayDeque (java.util.ArrayDeque)2 HashMap (java.util.HashMap)2 List (java.util.List)2 UserInterceptorFactory (org.jboss.as.ee.component.interceptors.UserInterceptorFactory)2 EJBComponentDescription (org.jboss.as.ejb3.component.EJBComponentDescription)2