Search in sources :

Example 16 with ViewConfigurator

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

the class StatelessComponentDescription method setupViewInterceptors.

@Override
protected void setupViewInterceptors(EJBViewDescription view) {
    // let super do its job first
    super.setupViewInterceptors(view);
    addViewSerializationInterceptor(view);
    // add the 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.getParameterCount() == 0) || method.getName().equals("equals") && method.getParameterCount() == 1 && method.getParameterTypes()[0] == Object.class) {
                    configuration.addClientInterceptor(method, ComponentTypeIdentityInterceptorFactory.INSTANCE, InterceptorOrder.Client.EJB_EQUALS_HASHCODE);
                }
            }
            // add the stateless component instance associating interceptor
            configuration.addViewInterceptor(StatelessComponentInstanceAssociatingFactory.instance(), 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)

Aggregations

ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)16 ViewConfiguration (org.jboss.as.ee.component.ViewConfiguration)16 ViewConfigurator (org.jboss.as.ee.component.ViewConfigurator)16 ViewDescription (org.jboss.as.ee.component.ViewDescription)16 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)16 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)16 EJBViewDescription (org.jboss.as.ejb3.component.EJBViewDescription)11 Method (java.lang.reflect.Method)9 ImmediateInterceptorFactory (org.jboss.invocation.ImmediateInterceptorFactory)7 DependencyConfigurator (org.jboss.as.ee.component.DependencyConfigurator)4 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)4 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)4 NamespaceViewConfigurator (org.jboss.as.ee.component.NamespaceViewConfigurator)3 ViewService (org.jboss.as.ee.component.ViewService)3 WriteReplaceInterface (org.jboss.as.ee.component.serialization.WriteReplaceInterface)3 EJBSecurityViewConfigurator (org.jboss.as.ejb3.security.EJBSecurityViewConfigurator)3 ClassReflectionIndex (org.jboss.as.server.deployment.reflect.ClassReflectionIndex)3 EJBHome (javax.ejb.EJBHome)2 Handle (javax.ejb.Handle)2 ComponentStartService (org.jboss.as.ee.component.ComponentStartService)2