Search in sources :

Example 11 with ComponentConfiguration

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

the class EjbManagementDeploymentUnitProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleConfiguration moduleDescription = deploymentUnit.getAttachment(EE_MODULE_CONFIGURATION);
    if (moduleDescription == null) {
        // Nothing to do
        return;
    }
    if (deploymentUnit.getParent() != null && deploymentUnit.getParent().getParent() != null) {
        // We only expose management resources 2 levels deep
        return;
    }
    // Iterate through each component, installing it into the container
    for (final ComponentConfiguration configuration : moduleDescription.getComponentConfigurations()) {
        try {
            final ComponentDescription componentDescription = configuration.getComponentDescription();
            if (componentDescription instanceof EJBComponentDescription) {
                installManagementResource(configuration, deploymentUnit);
            }
        } catch (RuntimeException e) {
            throw EjbLogger.ROOT_LOGGER.failedToInstallManagementResource(e, configuration.getComponentName());
        }
    }
}
Also used : ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EEModuleConfiguration(org.jboss.as.ee.component.EEModuleConfiguration) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription)

Example 12 with ComponentConfiguration

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

the class EJBComponentDescription method setupViewInterceptors.

protected void setupViewInterceptors(final EJBViewDescription view) {
    // add a logging interceptor (to take care of EJB3 spec, section 14.3 logging requirements)
    view.getConfigurators().add(new ViewConfigurator() {

        @Override
        public void configure(DeploymentPhaseContext context, ComponentConfiguration componentConfiguration, ViewDescription description, ViewConfiguration viewConfiguration) throws DeploymentUnitProcessingException {
            viewConfiguration.addViewInterceptor(LoggingInterceptor.FACTORY, InterceptorOrder.View.EJB_EXCEPTION_LOGGING_INTERCEPTOR);
            final ClassLoader classLoader = componentConfiguration.getModuleClassLoader();
            viewConfiguration.addViewInterceptor(AccessCheckingInterceptor.getFactory(), InterceptorOrder.View.CHECKING_INTERCEPTOR);
            viewConfiguration.addViewInterceptor(new ImmediateInterceptorFactory(new ContextClassLoaderInterceptor(classLoader)), InterceptorOrder.View.TCCL_INTERCEPTOR);
            //If this is the EJB 2.x local or home view add the exception transformer interceptor
            if (view.getMethodIntf() == MethodIntf.LOCAL && EJBLocalObject.class.isAssignableFrom(viewConfiguration.getViewClass())) {
                viewConfiguration.addViewInterceptor(EjbExceptionTransformingInterceptorFactories.LOCAL_INSTANCE, InterceptorOrder.View.REMOTE_EXCEPTION_TRANSFORMER);
            } else if (view.getMethodIntf() == MethodIntf.LOCAL_HOME) {
                viewConfiguration.addViewInterceptor(EjbExceptionTransformingInterceptorFactories.LOCAL_INSTANCE, InterceptorOrder.View.REMOTE_EXCEPTION_TRANSFORMER);
            }
            final List<SetupAction> ejbSetupActions = context.getDeploymentUnit().getAttachmentList(Attachments.OTHER_EE_SETUP_ACTIONS);
            if (!ejbSetupActions.isEmpty()) {
                viewConfiguration.addViewInterceptor(AdditionalSetupInterceptor.factory(ejbSetupActions), InterceptorOrder.View.EE_SETUP);
            }
            viewConfiguration.addViewInterceptor(WaitTimeInterceptor.FACTORY, InterceptorOrder.View.EJB_WAIT_TIME_INTERCEPTOR);
            viewConfiguration.addViewInterceptor(shutDownInterceptorFactory, InterceptorOrder.View.SHUTDOWN_INTERCEPTOR);
        }
    });
    this.addCurrentInvocationContextFactory(view);
    this.setupSecurityInterceptors(view);
    this.setupRemoteViewInterceptors(view);
    view.getConfigurators().addFirst(new NamespaceViewConfigurator());
}
Also used : NamespaceViewConfigurator(org.jboss.as.ee.component.NamespaceViewConfigurator) EJBRemoteTransactionsViewConfigurator(org.jboss.as.ejb3.remote.EJBRemoteTransactionsViewConfigurator) EJBSecurityViewConfigurator(org.jboss.as.ejb3.security.EJBSecurityViewConfigurator) ViewConfigurator(org.jboss.as.ee.component.ViewConfigurator) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ViewConfiguration(org.jboss.as.ee.component.ViewConfiguration) ViewDescription(org.jboss.as.ee.component.ViewDescription) ImmediateInterceptorFactory(org.jboss.invocation.ImmediateInterceptorFactory) ContextClassLoaderInterceptor(org.jboss.invocation.ContextClassLoaderInterceptor) NamespaceViewConfigurator(org.jboss.as.ee.component.NamespaceViewConfigurator) ArrayList(java.util.ArrayList) List(java.util.List) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext)

Example 13 with ComponentConfiguration

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

the class EJBComponentDescription method setupRemoteViewInterceptors.

private void setupRemoteViewInterceptors(final EJBViewDescription view) {
    if (view.getMethodIntf() == MethodIntf.REMOTE || view.getMethodIntf() == MethodIntf.HOME) {
        view.getConfigurators().add(new ViewConfigurator() {

            @Override
            public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException {
                if (Remote.class.isAssignableFrom(configuration.getViewClass())) {
                    configuration.addViewInterceptor(EjbExceptionTransformingInterceptorFactories.REMOTE_INSTANCE, InterceptorOrder.View.REMOTE_EXCEPTION_TRANSFORMER);
                }
            }
        });
        if (view.getMethodIntf() == MethodIntf.HOME) {
            view.getConfigurators().add(new ViewConfigurator() {

                @Override
                public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException {
                    if (Remote.class.isAssignableFrom(configuration.getViewClass())) {
                        final String earApplicationName = componentConfiguration.getComponentDescription().getModuleDescription().getEarApplicationName();
                        configuration.setViewInstanceFactory(new RemoteHomeViewInstanceFactory(earApplicationName, componentConfiguration.getModuleName(), componentConfiguration.getComponentDescription().getModuleDescription().getDistinctName(), componentConfiguration.getComponentName()));
                    }
                }
            });
        }
        // add the remote tx propagating interceptor
        view.getConfigurators().add(new EJBRemoteTransactionsViewConfigurator());
    }
}
Also used : NamespaceViewConfigurator(org.jboss.as.ee.component.NamespaceViewConfigurator) EJBRemoteTransactionsViewConfigurator(org.jboss.as.ejb3.remote.EJBRemoteTransactionsViewConfigurator) EJBSecurityViewConfigurator(org.jboss.as.ejb3.security.EJBSecurityViewConfigurator) ViewConfigurator(org.jboss.as.ee.component.ViewConfigurator) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) EJBRemoteTransactionsViewConfigurator(org.jboss.as.ejb3.remote.EJBRemoteTransactionsViewConfigurator) ViewConfiguration(org.jboss.as.ee.component.ViewConfiguration) ViewDescription(org.jboss.as.ee.component.ViewDescription) Remote(java.rmi.Remote) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext)

Example 14 with ComponentConfiguration

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

the class SingletonComponentDescription method setupViewInterceptors.

@Override
protected void setupViewInterceptors(EJBViewDescription view) {
    // let super do its job first
    super.setupViewInterceptors(view);
    addViewSerializationInterceptor(view);
    // add container managed concurrency interceptor to the component
    this.addConcurrencyManagementInterceptor(view);
    // add instance associating interceptor at the start of the interceptor chain
    view.getConfigurators().addFirst(new ViewConfigurator() {

        @Override
        public void configure(DeploymentPhaseContext context, ComponentConfiguration componentConfiguration, ViewDescription description, ViewConfiguration configuration) throws DeploymentUnitProcessingException {
            //add equals/hashCode interceptor
            for (Method method : configuration.getProxyFactory().getCachedMethods()) {
                if ((method.getName().equals("hashCode") && method.getParameterTypes().length == 0) || method.getName().equals("equals") && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == Object.class) {
                    configuration.addClientInterceptor(method, ComponentTypeIdentityInterceptorFactory.INSTANCE, InterceptorOrder.Client.EJB_EQUALS_HASHCODE);
                }
            }
            // add the singleton component instance associating interceptor
            configuration.addViewInterceptor(SingletonComponentInstanceAssociationInterceptor.FACTORY, InterceptorOrder.View.ASSOCIATING_INTERCEPTOR);
        }
    });
    if (view.getMethodIntf() == MethodIntf.REMOTE) {
        view.getConfigurators().add(new ViewConfigurator() {

            @Override
            public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException {
                final String earApplicationName = componentConfiguration.getComponentDescription().getModuleDescription().getEarApplicationName();
                configuration.setViewInstanceFactory(new StatelessRemoteViewInstanceFactory(earApplicationName, componentConfiguration.getModuleName(), componentConfiguration.getComponentDescription().getModuleDescription().getDistinctName(), componentConfiguration.getComponentName()));
            }
        });
    }
}
Also used : ViewConfigurator(org.jboss.as.ee.component.ViewConfigurator) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ViewConfiguration(org.jboss.as.ee.component.ViewConfiguration) EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) ViewDescription(org.jboss.as.ee.component.ViewDescription) StatelessRemoteViewInstanceFactory(org.jboss.as.ejb3.component.session.StatelessRemoteViewInstanceFactory) Method(java.lang.reflect.Method) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext)

Example 15 with ComponentConfiguration

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

the class StatefulComponentDescription method setupViewInterceptors.

@Override
protected void setupViewInterceptors(EJBViewDescription view) {
    // let super do its job
    super.setupViewInterceptors(view);
    // add the @Remove method interceptor
    this.addRemoveMethodInterceptor(view);
    // setup the instance associating interceptors
    this.addStatefulInstanceAssociatingInterceptor(view);
    this.addViewSerializationInterceptor(view);
    if (view.getMethodIntf() == MethodIntf.REMOTE) {
        view.getConfigurators().add(new ViewConfigurator() {

            @Override
            public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException {
                final String earApplicationName = componentConfiguration.getComponentDescription().getModuleDescription().getEarApplicationName();
                configuration.setViewInstanceFactory(new StatefulRemoteViewInstanceFactory(earApplicationName, componentConfiguration.getModuleName(), componentConfiguration.getComponentDescription().getModuleDescription().getDistinctName(), componentConfiguration.getComponentName()));
            }
        });
    }
}
Also used : ViewConfigurator(org.jboss.as.ee.component.ViewConfigurator) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ViewConfiguration(org.jboss.as.ee.component.ViewConfiguration) EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) ViewDescription(org.jboss.as.ee.component.ViewDescription) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext)

Aggregations

ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)37 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)28 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)26 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)19 ViewConfiguration (org.jboss.as.ee.component.ViewConfiguration)19 ComponentConfigurator (org.jboss.as.ee.component.ComponentConfigurator)16 ViewConfigurator (org.jboss.as.ee.component.ViewConfigurator)15 ViewDescription (org.jboss.as.ee.component.ViewDescription)15 ImmediateInterceptorFactory (org.jboss.invocation.ImmediateInterceptorFactory)14 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)13 EJBViewDescription (org.jboss.as.ejb3.component.EJBViewDescription)11 Method (java.lang.reflect.Method)10 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)9 ServiceName (org.jboss.msc.service.ServiceName)8 EJBComponentDescription (org.jboss.as.ejb3.component.EJBComponentDescription)7 DependencyConfigurator (org.jboss.as.ee.component.DependencyConfigurator)6 EEModuleConfiguration (org.jboss.as.ee.component.EEModuleConfiguration)6 SessionBeanComponentDescription (org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)6 Module (org.jboss.modules.Module)6 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)6