Search in sources :

Example 21 with ViewDescription

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

the class AsynchronousMergingProcessor method handleDeploymentDescriptor.

@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final SessionBeanComponentDescription description) throws DeploymentUnitProcessingException {
    final SessionBeanMetaData data = description.getDescriptorData();
    final boolean isSecurityDomainKnown = description.isSecurityDomainKnown();
    if (data != null) {
        if (data instanceof SessionBean31MetaData) {
            final SessionBean31MetaData sessionBeanData = (SessionBean31MetaData) data;
            final AsyncMethodsMetaData async = sessionBeanData.getAsyncMethods();
            if (async != null) {
                for (AsyncMethodMetaData method : async) {
                    final Collection<Method> methods = MethodResolutionUtils.resolveMethods(method.getMethodName(), method.getMethodParams(), componentClass, deploymentReflectionIndex);
                    for (final Method m : methods) {
                        description.addAsynchronousMethod(MethodIdentifier.getIdentifierForMethod(m));
                    }
                }
            }
        }
    }
    if (!description.getAsynchronousClasses().isEmpty() || !description.getAsynchronousMethods().isEmpty()) {
        //setup a dependency on the executor service
        description.getConfigurators().add(new ComponentConfigurator() {

            @Override
            public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
                configuration.getCreateDependencies().add(new DependencyConfigurator<SessionBeanComponentCreateService>() {

                    @Override
                    public void configureDependency(final ServiceBuilder<?> serviceBuilder, final SessionBeanComponentCreateService service) throws DeploymentUnitProcessingException {
                        serviceBuilder.addDependency(asynchronousThreadPoolService, ExecutorService.class, service.getAsyncExecutorService());
                    }
                });
            }
        });
        for (final ViewDescription view : description.getViews()) {
            final EJBViewDescription ejbView = (EJBViewDescription) view;
            ejbView.getConfigurators().add(new ViewConfigurator() {

                @Override
                public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException {
                    final SessionBeanComponentDescription componentDescription = (SessionBeanComponentDescription) componentConfiguration.getComponentDescription();
                    for (final Method method : configuration.getProxyFactory().getCachedMethods()) {
                        //we need the component method to get the correct declaring class
                        final Method componentMethod = ClassReflectionIndexUtil.findMethod(deploymentReflectionIndex, componentClass, method);
                        if (componentMethod != null) {
                            if (componentDescription.getAsynchronousClasses().contains(componentMethod.getDeclaringClass().getName())) {
                                addAsyncInterceptor(configuration, method, isSecurityDomainKnown);
                                configuration.addAsyncMethod(method);
                            } else {
                                MethodIdentifier id = MethodIdentifier.getIdentifierForMethod(method);
                                if (componentDescription.getAsynchronousMethods().contains(id)) {
                                    addAsyncInterceptor(configuration, method, isSecurityDomainKnown);
                                    configuration.addAsyncMethod(method);
                                }
                            }
                        }
                    }
                }
            });
        }
    }
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ViewConfigurator(org.jboss.as.ee.component.ViewConfigurator) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) ComponentConfigurator(org.jboss.as.ee.component.ComponentConfigurator) SessionBeanMetaData(org.jboss.metadata.ejb.spec.SessionBeanMetaData) EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) ViewDescription(org.jboss.as.ee.component.ViewDescription) DependencyConfigurator(org.jboss.as.ee.component.DependencyConfigurator) Method(java.lang.reflect.Method) MethodIdentifier(org.jboss.invocation.proxy.MethodIdentifier) SessionBean31MetaData(org.jboss.metadata.ejb.spec.SessionBean31MetaData) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) AsyncMethodsMetaData(org.jboss.metadata.ejb.spec.AsyncMethodsMetaData) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) ViewConfiguration(org.jboss.as.ee.component.ViewConfiguration) AsyncMethodMetaData(org.jboss.metadata.ejb.spec.AsyncMethodMetaData) SessionBeanComponentCreateService(org.jboss.as.ejb3.component.session.SessionBeanComponentCreateService) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)

Aggregations

ViewDescription (org.jboss.as.ee.component.ViewDescription)21 EJBViewDescription (org.jboss.as.ejb3.component.EJBViewDescription)15 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)15 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)14 ViewConfiguration (org.jboss.as.ee.component.ViewConfiguration)14 ViewConfigurator (org.jboss.as.ee.component.ViewConfigurator)14 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)14 Method (java.lang.reflect.Method)8 ImmediateInterceptorFactory (org.jboss.invocation.ImmediateInterceptorFactory)6 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)5 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)4 ClassReflectionIndex (org.jboss.as.server.deployment.reflect.ClassReflectionIndex)4 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)3 WriteReplaceInterface (org.jboss.as.ee.component.serialization.WriteReplaceInterface)3 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)3 Module (org.jboss.modules.Module)3 HashSet (java.util.HashSet)2 ComponentView (org.jboss.as.ee.component.ComponentView)2 DependencyConfigurator (org.jboss.as.ee.component.DependencyConfigurator)2 NamespaceViewConfigurator (org.jboss.as.ee.component.NamespaceViewConfigurator)2