Search in sources :

Example 21 with DeploymentReflectionIndex

use of org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex in project wildfly by wildfly.

the class HomeViewMergingProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    if (eeModuleDescription == null) {
        return;
    }
    final Collection<ComponentDescription> componentConfigurations = eeModuleDescription.getComponentDescriptions();
    final DeploymentReflectionIndex deploymentReflectionIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
    final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
    for (ComponentDescription componentConfiguration : componentConfigurations) {
        if (componentConfiguration instanceof SessionBeanComponentDescription) {
            try {
                processComponentConfig(deploymentUnit, applicationClasses, module, deploymentReflectionIndex, (SessionBeanComponentDescription) componentConfiguration);
            } catch (Exception e) {
                throw EjbLogger.ROOT_LOGGER.failToMergeData(componentConfiguration.getComponentName(), e);
            }
        }
    }
    if (appclient) {
        for (ComponentDescription componentDescription : deploymentUnit.getAttachmentList(Attachments.ADDITIONAL_RESOLVABLE_COMPONENTS)) {
            if (componentDescription instanceof SessionBeanComponentDescription) {
                try {
                    processComponentConfig(deploymentUnit, applicationClasses, module, deploymentReflectionIndex, (SessionBeanComponentDescription) componentDescription);
                } catch (Exception e) {
                    throw EjbLogger.ROOT_LOGGER.failToMergeData(componentDescription.getComponentName(), e);
                }
            }
        }
    }
}
Also used : ComponentDescription(org.jboss.as.ee.component.ComponentDescription) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException)

Example 22 with DeploymentReflectionIndex

use of org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex in project wildfly by wildfly.

the class DeploymentDescriptorInterceptorBindingsProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EjbJarMetaData metaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    final DeploymentReflectionIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
    if (metaData == null) {
        return;
    }
    if (metaData.getAssemblyDescriptor() == null) {
        return;
    }
    if (metaData.getAssemblyDescriptor().getInterceptorBindings() == null) {
        return;
    }
    //default interceptors must be mentioned in the interceptors section
    final Set<String> interceptorClasses = new HashSet<String>();
    if (metaData.getInterceptors() != null) {
        for (final InterceptorMetaData interceptor : metaData.getInterceptors()) {
            interceptorClasses.add(interceptor.getInterceptorClass());
        }
    }
    final Map<String, List<InterceptorBindingMetaData>> bindingsPerComponent = new HashMap<String, List<InterceptorBindingMetaData>>();
    final List<InterceptorBindingMetaData> defaultInterceptorBindings = new ArrayList<InterceptorBindingMetaData>();
    for (final InterceptorBindingMetaData binding : metaData.getAssemblyDescriptor().getInterceptorBindings()) {
        if (binding.getEjbName().equals("*")) {
            if (binding.getMethod() != null) {
                throw EjbLogger.ROOT_LOGGER.defaultInterceptorsNotBindToMethod();
            }
            if (binding.getInterceptorOrder() != null) {
                throw EjbLogger.ROOT_LOGGER.defaultInterceptorsNotSpecifyOrder();
            }
            defaultInterceptorBindings.add(binding);
        } else if (ejbNameRegexService.isEjbNameRegexAllowed()) {
            Pattern pattern = Pattern.compile(binding.getEjbName());
            for (final ComponentDescription componentDescription : eeModuleDescription.getComponentDescriptions()) {
                if (componentDescription instanceof EJBComponentDescription) {
                    String ejbName = ((EJBComponentDescription) componentDescription).getEJBName();
                    if (pattern.matcher(ejbName).matches()) {
                        List<InterceptorBindingMetaData> bindings = bindingsPerComponent.get(ejbName);
                        if (bindings == null) {
                            bindingsPerComponent.put(ejbName, bindings = new ArrayList<InterceptorBindingMetaData>());
                        }
                        bindings.add(binding);
                    }
                }
            }
        } else {
            List<InterceptorBindingMetaData> bindings = bindingsPerComponent.get(binding.getEjbName());
            if (bindings == null) {
                bindingsPerComponent.put(binding.getEjbName(), bindings = new ArrayList<InterceptorBindingMetaData>());
            }
            bindings.add(binding);
        }
    }
    final List<InterceptorDescription> defaultInterceptors = new ArrayList<InterceptorDescription>();
    for (InterceptorBindingMetaData binding : defaultInterceptorBindings) {
        if (binding.getInterceptorClasses() != null) {
            for (final String clazz : binding.getInterceptorClasses()) {
                //we only want default interceptors referenced in the interceptors section
                if (interceptorClasses.contains(clazz)) {
                    defaultInterceptors.add(new InterceptorDescription(clazz));
                } else {
                    ROOT_LOGGER.defaultInterceptorClassNotListed(clazz);
                }
            }
        }
    }
    //we iterate over all components, as we need to process default interceptors
    for (final ComponentDescription componentDescription : eeModuleDescription.getComponentDescriptions()) {
        final Class<?> componentClass;
        try {
            componentClass = module.getClassLoader().loadClass(componentDescription.getComponentClassName());
        } catch (ClassNotFoundException e) {
            throw EjbLogger.ROOT_LOGGER.failToLoadComponentClass(e, componentDescription.getComponentClassName());
        }
        final List<InterceptorBindingMetaData> bindings = bindingsPerComponent.get(componentDescription.getComponentName());
        final Map<Method, List<InterceptorBindingMetaData>> methodInterceptors = new HashMap<Method, List<InterceptorBindingMetaData>>();
        final List<InterceptorBindingMetaData> classLevelBindings = new ArrayList<InterceptorBindingMetaData>();
        //we only want to exclude default and class level interceptors if every binding
        //has the exclude element.
        boolean classLevelExcludeDefaultInterceptors = false;
        Map<Method, Boolean> methodLevelExcludeDefaultInterceptors = new HashMap<Method, Boolean>();
        Map<Method, Boolean> methodLevelExcludeClassInterceptors = new HashMap<Method, Boolean>();
        //if an absolute order has been defined at any level
        //absolute ordering takes precedence
        boolean classLevelAbsoluteOrder = false;
        final Map<Method, Boolean> methodLevelAbsoluteOrder = new HashMap<Method, Boolean>();
        if (bindings != null) {
            for (final InterceptorBindingMetaData binding : bindings) {
                if (binding.getMethod() == null) {
                    classLevelBindings.add(binding);
                    //if even one binding does not say exclude default then we do not exclude
                    if (binding.isExcludeDefaultInterceptors()) {
                        classLevelExcludeDefaultInterceptors = true;
                    }
                    if (binding.isTotalOrdering()) {
                        if (classLevelAbsoluteOrder) {
                            throw EjbLogger.ROOT_LOGGER.twoEjbBindingsSpecifyAbsoluteOrder(componentClass.toString());
                        } else {
                            classLevelAbsoluteOrder = true;
                        }
                    }
                } else {
                    //method level bindings
                    //first find the right method
                    final NamedMethodMetaData methodData = binding.getMethod();
                    final ClassReflectionIndex classIndex = index.getClassIndex(componentClass);
                    Method resolvedMethod = null;
                    if (methodData.getMethodParams() == null) {
                        final Collection<Method> methods = classIndex.getAllMethods(methodData.getMethodName());
                        if (methods.isEmpty()) {
                            throw EjbLogger.ROOT_LOGGER.failToFindMethodInEjbJarXml(componentClass.getName(), methodData.getMethodName());
                        } else if (methods.size() > 1) {
                            throw EjbLogger.ROOT_LOGGER.multipleMethodReferencedInEjbJarXml(methodData.getMethodName(), componentClass.getName());
                        }
                        resolvedMethod = methods.iterator().next();
                    } else {
                        final Collection<Method> methods = classIndex.getAllMethods(methodData.getMethodName(), methodData.getMethodParams().size());
                        for (final Method method : methods) {
                            boolean match = true;
                            for (int i = 0; i < method.getParameterTypes().length; ++i) {
                                if (!method.getParameterTypes()[i].getName().equals(methodData.getMethodParams().get(i))) {
                                    match = false;
                                    break;
                                }
                            }
                            if (match) {
                                resolvedMethod = method;
                                break;
                            }
                        }
                        if (resolvedMethod == null) {
                            throw EjbLogger.ROOT_LOGGER.failToFindMethodWithParameterTypes(componentClass.getName(), methodData.getMethodName(), methodData.getMethodParams());
                        }
                    }
                    List<InterceptorBindingMetaData> list = methodInterceptors.get(resolvedMethod);
                    if (list == null) {
                        methodInterceptors.put(resolvedMethod, list = new ArrayList<InterceptorBindingMetaData>());
                    }
                    list.add(binding);
                    if (binding.isExcludeDefaultInterceptors()) {
                        methodLevelExcludeDefaultInterceptors.put(resolvedMethod, true);
                    }
                    if (binding.isExcludeClassInterceptors()) {
                        methodLevelExcludeClassInterceptors.put(resolvedMethod, true);
                    }
                    if (binding.isTotalOrdering()) {
                        if (methodLevelAbsoluteOrder.containsKey(resolvedMethod)) {
                            throw EjbLogger.ROOT_LOGGER.twoEjbBindingsSpecifyAbsoluteOrder(resolvedMethod.toString());
                        } else {
                            methodLevelAbsoluteOrder.put(resolvedMethod, true);
                        }
                    }
                }
            }
        }
        //now we have all the bindings in a format we can use
        //build the list of default interceptors
        componentDescription.setDefaultInterceptors(defaultInterceptors);
        if (classLevelExcludeDefaultInterceptors) {
            componentDescription.setExcludeDefaultInterceptors(true);
        }
        final List<InterceptorDescription> classLevelInterceptors = new ArrayList<InterceptorDescription>();
        if (classLevelAbsoluteOrder) {
            //we have an absolute ordering for the class level interceptors
            for (final InterceptorBindingMetaData binding : classLevelBindings) {
                if (binding.isTotalOrdering()) {
                    for (final String interceptor : binding.getInterceptorOrder()) {
                        classLevelInterceptors.add(new InterceptorDescription(interceptor));
                    }
                }
            }
            //we have merged the default interceptors into the class interceptors
            componentDescription.setExcludeDefaultInterceptors(true);
        } else {
            //the order we want is default interceptors (this will be empty if they are excluded)
            //the annotation interceptors
            //then dd interceptors
            classLevelInterceptors.addAll(componentDescription.getClassInterceptors());
            for (InterceptorBindingMetaData binding : classLevelBindings) {
                if (binding.getInterceptorClasses() != null) {
                    for (final String interceptor : binding.getInterceptorClasses()) {
                        classLevelInterceptors.add(new InterceptorDescription(interceptor));
                    }
                }
            }
        }
        componentDescription.setClassInterceptors(classLevelInterceptors);
        for (Map.Entry<Method, List<InterceptorBindingMetaData>> entry : methodInterceptors.entrySet()) {
            final Method method = entry.getKey();
            final List<InterceptorBindingMetaData> methodBindings = entry.getValue();
            boolean totalOrder = methodLevelAbsoluteOrder.containsKey(method);
            final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifierForMethod(method);
            Boolean excludeDefaultInterceptors = methodLevelExcludeDefaultInterceptors.get(method);
            excludeDefaultInterceptors = excludeDefaultInterceptors == null ? false : excludeDefaultInterceptors;
            if (!excludeDefaultInterceptors) {
                excludeDefaultInterceptors = componentDescription.isExcludeDefaultInterceptors() || componentDescription.isExcludeDefaultInterceptors(methodIdentifier);
            }
            Boolean excludeClassInterceptors = methodLevelExcludeClassInterceptors.get(method);
            excludeClassInterceptors = excludeClassInterceptors == null ? false : excludeClassInterceptors;
            if (!excludeClassInterceptors) {
                excludeClassInterceptors = componentDescription.isExcludeClassInterceptors(methodIdentifier);
            }
            final List<InterceptorDescription> methodLevelInterceptors = new ArrayList<InterceptorDescription>();
            if (totalOrder) {
                //if there is a total order we just use it
                for (final InterceptorBindingMetaData binding : methodBindings) {
                    if (binding.isTotalOrdering()) {
                        for (final String interceptor : binding.getInterceptorOrder()) {
                            methodLevelInterceptors.add(new InterceptorDescription(interceptor));
                        }
                    }
                }
            } else {
                //class level interceptors also includes default interceptors
                if (!excludeDefaultInterceptors) {
                    methodLevelInterceptors.addAll(defaultInterceptors);
                }
                if (!excludeClassInterceptors) {
                    for (InterceptorDescription interceptor : classLevelInterceptors) {
                        methodLevelInterceptors.add(interceptor);
                    }
                }
                List<InterceptorDescription> annotationMethodLevel = componentDescription.getMethodInterceptors().get(methodIdentifier);
                if (annotationMethodLevel != null) {
                    methodLevelInterceptors.addAll(annotationMethodLevel);
                }
                //now add all the interceptors from the bindings
                for (InterceptorBindingMetaData binding : methodBindings) {
                    if (binding.getInterceptorClasses() != null) {
                        for (final String interceptor : binding.getInterceptorClasses()) {
                            methodLevelInterceptors.add(new InterceptorDescription(interceptor));
                        }
                    }
                }
            }
            //we have already taken component and default interceptors into account
            componentDescription.excludeClassInterceptors(methodIdentifier);
            componentDescription.excludeDefaultInterceptors(methodIdentifier);
            componentDescription.setMethodInterceptors(methodIdentifier, methodLevelInterceptors);
        }
    }
}
Also used : EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) HashMap(java.util.HashMap) InterceptorBindingMetaData(org.jboss.metadata.ejb.spec.InterceptorBindingMetaData) ArrayList(java.util.ArrayList) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) InterceptorDescription(org.jboss.as.ee.component.InterceptorDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet) Pattern(java.util.regex.Pattern) EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) NamedMethodMetaData(org.jboss.metadata.ejb.spec.NamedMethodMetaData) ClassReflectionIndex(org.jboss.as.server.deployment.reflect.ClassReflectionIndex) Method(java.lang.reflect.Method) MethodIdentifier(org.jboss.invocation.proxy.MethodIdentifier) InterceptorMetaData(org.jboss.metadata.ejb.spec.InterceptorMetaData) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex) HashMap(java.util.HashMap) Map(java.util.Map)

Example 23 with DeploymentReflectionIndex

use of org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex in project wildfly by wildfly.

the class SessionBeanComponentDescription method addNoInterfaceView.

public void addNoInterfaceView() {
    noInterfaceViewPresent = true;
    final ViewDescription viewDescription = registerView(getEJBClassName(), MethodIntf.LOCAL);
    //set up interceptor for non-business methods
    viewDescription.getConfigurators().add(new ViewConfigurator() {

        @Override
        public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException {
            DeploymentReflectionIndex index = context.getDeploymentUnit().getAttachment(Attachments.REFLECTION_INDEX);
            for (final Method method : configuration.getProxyFactory().getCachedMethods()) {
                if (!Modifier.isPublic(method.getModifiers()) && isNotOverriden(method, componentConfiguration.getComponentClass(), index)) {
                    configuration.addClientInterceptor(method, new ImmediateInterceptorFactory(new NotBusinessMethodInterceptor(method)), InterceptorOrder.Client.NOT_BUSINESS_METHOD_EXCEPTION);
                }
            }
        }
    });
}
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) ImmediateInterceptorFactory(org.jboss.invocation.ImmediateInterceptorFactory) Method(java.lang.reflect.Method) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)

Example 24 with DeploymentReflectionIndex

use of org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex in project wildfly by wildfly.

the class SessionBeanObjectViewConfigurator method configure.

@Override
public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException {
    //note that we don't have to handle all methods on the EJBObject, as some are handled client side
    final DeploymentReflectionIndex index = context.getDeploymentUnit().getAttachment(Attachments.REFLECTION_INDEX);
    for (final Method method : configuration.getProxyFactory().getCachedMethods()) {
        if (method.getName().equals("getPrimaryKey") && method.getParameterTypes().length == 0) {
            configuration.addClientInterceptor(method, ViewDescription.CLIENT_DISPATCHER_INTERCEPTOR_FACTORY, InterceptorOrder.Client.CLIENT_DISPATCHER);
            configuration.addViewInterceptor(method, PRIMARY_KEY_INTERCEPTOR, InterceptorOrder.View.COMPONENT_DISPATCHER);
        } else if (method.getName().equals("remove") && method.getParameterTypes().length == 0) {
            handleRemoveMethod(componentConfiguration, configuration, index, method);
        } else if (method.getName().equals("getEJBLocalHome") && method.getParameterTypes().length == 0) {
            configuration.addClientInterceptor(method, ViewDescription.CLIENT_DISPATCHER_INTERCEPTOR_FACTORY, InterceptorOrder.Client.CLIENT_DISPATCHER);
            final GetHomeInterceptorFactory factory = new GetHomeInterceptorFactory();
            configuration.addViewInterceptor(method, factory, InterceptorOrder.View.COMPONENT_DISPATCHER);
            final SessionBeanComponentDescription componentDescription = (SessionBeanComponentDescription) componentConfiguration.getComponentDescription();
            componentConfiguration.getStartDependencies().add(new DependencyConfigurator<ComponentStartService>() {

                @Override
                public void configureDependency(final ServiceBuilder<?> serviceBuilder, final ComponentStartService service) throws DeploymentUnitProcessingException {
                    EjbHomeViewDescription ejbLocalHomeView = componentDescription.getEjbLocalHomeView();
                    if (ejbLocalHomeView == null) {
                        throw EjbLogger.ROOT_LOGGER.beanLocalHomeInterfaceIsNull(componentDescription.getComponentName());
                    }
                    serviceBuilder.addDependency(ejbLocalHomeView.getServiceName(), ComponentView.class, factory.getViewToCreate());
                }
            });
        } else if (method.getName().equals("getEJBHome") && method.getParameterTypes().length == 0) {
            configuration.addClientInterceptor(method, ViewDescription.CLIENT_DISPATCHER_INTERCEPTOR_FACTORY, InterceptorOrder.Client.CLIENT_DISPATCHER);
            final GetHomeInterceptorFactory factory = new GetHomeInterceptorFactory();
            configuration.addViewInterceptor(method, factory, InterceptorOrder.View.COMPONENT_DISPATCHER);
            final SessionBeanComponentDescription componentDescription = (SessionBeanComponentDescription) componentConfiguration.getComponentDescription();
            componentConfiguration.getStartDependencies().add(new DependencyConfigurator<ComponentStartService>() {

                @Override
                public void configureDependency(final ServiceBuilder<?> serviceBuilder, final ComponentStartService service) throws DeploymentUnitProcessingException {
                    EjbHomeViewDescription ejbHomeView = componentDescription.getEjbHomeView();
                    if (ejbHomeView == null) {
                        throw EjbLogger.ROOT_LOGGER.beanHomeInterfaceIsNull(componentDescription.getComponentName());
                    }
                    serviceBuilder.addDependency(ejbHomeView.getServiceName(), ComponentView.class, factory.getViewToCreate());
                }
            });
        } else if (method.getName().equals("getHandle") && method.getParameterTypes().length == 0) {
        //ignore, handled client side
        } else if (method.getName().equals("isIdentical") && method.getParameterTypes().length == 1 && (method.getParameterTypes()[0].equals(EJBObject.class) || method.getParameterTypes()[0].equals(EJBLocalObject.class))) {
            handleIsIdenticalMethod(componentConfiguration, configuration, index, method);
        } else {
            final Method componentMethod = ClassReflectionIndexUtil.findMethod(index, componentConfiguration.getComponentClass(), MethodIdentifier.getIdentifierForMethod(method));
            if (componentMethod != null) {
                if (!Modifier.isPublic(componentMethod.getModifiers())) {
                    throw EjbLogger.ROOT_LOGGER.ejbBusinessMethodMustBePublic(componentMethod);
                }
                configuration.addViewInterceptor(method, new ImmediateInterceptorFactory(new ComponentDispatcherInterceptor(componentMethod)), InterceptorOrder.View.COMPONENT_DISPATCHER);
                configuration.addClientInterceptor(method, ViewDescription.CLIENT_DISPATCHER_INTERCEPTOR_FACTORY, InterceptorOrder.Client.CLIENT_DISPATCHER);
            } else if (method.getDeclaringClass() != Object.class && method.getDeclaringClass() != WriteReplaceInterface.class) {
                throw EjbLogger.ROOT_LOGGER.couldNotFindViewMethodOnEjb(method, description.getViewClassName(), componentConfiguration.getComponentName());
            }
        }
    }
    configuration.addClientPostConstructInterceptor(Interceptors.getTerminalInterceptorFactory(), InterceptorOrder.ClientPostConstruct.TERMINAL_INTERCEPTOR);
    configuration.addClientPreDestroyInterceptor(Interceptors.getTerminalInterceptorFactory(), InterceptorOrder.ClientPreDestroy.TERMINAL_INTERCEPTOR);
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) GetHomeInterceptorFactory(org.jboss.as.ejb3.component.interceptors.GetHomeInterceptorFactory) EjbHomeViewDescription(org.jboss.as.ejb3.component.EjbHomeViewDescription) DependencyConfigurator(org.jboss.as.ee.component.DependencyConfigurator) Method(java.lang.reflect.Method) WriteReplaceInterface(org.jboss.as.ee.component.serialization.WriteReplaceInterface) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) ComponentView(org.jboss.as.ee.component.ComponentView) ImmediateInterceptorFactory(org.jboss.invocation.ImmediateInterceptorFactory) EJBObject(javax.ejb.EJBObject) EJBLocalObject(javax.ejb.EJBLocalObject) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex) ComponentDispatcherInterceptor(org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor) ComponentStartService(org.jboss.as.ee.component.ComponentStartService)

Example 25 with DeploymentReflectionIndex

use of org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex in project wildfly by wildfly.

the class EjbIIOPDeploymentUnitProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (!IIOPDeploymentMarker.isIIOPDeployment(deploymentUnit)) {
        return;
    }
    final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    if (!EjbDeploymentMarker.isEjbDeployment(deploymentUnit)) {
        return;
    }
    // a bean-name -> IIOPMetaData map, reflecting the assembly descriptor IIOP configuration.
    Map<String, IIOPMetaData> iiopMetaDataMap = new HashMap<String, IIOPMetaData>();
    final EjbJarMetaData ejbMetaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
    if (ejbMetaData != null && ejbMetaData.getAssemblyDescriptor() != null) {
        List<IIOPMetaData> iiopMetaDatas = ejbMetaData.getAssemblyDescriptor().getAny(IIOPMetaData.class);
        if (iiopMetaDatas != null && iiopMetaDatas.size() > 0) {
            for (IIOPMetaData metaData : iiopMetaDatas) {
                iiopMetaDataMap.put(metaData.getEjbName(), metaData);
            }
        }
    }
    final DeploymentReflectionIndex deploymentReflectionIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
    final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    if (moduleDescription != null) {
        for (final ComponentDescription componentDescription : moduleDescription.getComponentDescriptions()) {
            if (componentDescription instanceof EJBComponentDescription) {
                final EJBComponentDescription ejbComponentDescription = (EJBComponentDescription) componentDescription;
                if (ejbComponentDescription.getEjbRemoteView() != null && ejbComponentDescription.getEjbHomeView() != null) {
                    // check if there is IIOP metadata for the bean - first using the bean name, then the wildcard "*" if needed.
                    IIOPMetaData iiopMetaData = iiopMetaDataMap.get(ejbComponentDescription.getEJBName());
                    if (iiopMetaData == null) {
                        iiopMetaData = iiopMetaDataMap.get(IIOPMetaData.WILDCARD_BEAN_NAME);
                    }
                    // has been enabled by default in the EJB3 subsystem.
                    if (iiopMetaData != null || settingsService.isEnabledByDefault()) {
                        processEjb(ejbComponentDescription, deploymentReflectionIndex, module, phaseContext.getServiceTarget(), iiopMetaData);
                    }
                }
            }
        }
    }
}
Also used : EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) HashMap(java.util.HashMap) IIOPMetaData(org.jboss.metadata.ejb.jboss.IIOPMetaData) EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription)

Aggregations

DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)31 Module (org.jboss.modules.Module)19 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)18 Method (java.lang.reflect.Method)14 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)14 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)11 ClassReflectionIndex (org.jboss.as.server.deployment.reflect.ClassReflectionIndex)10 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)9 EJBComponentDescription (org.jboss.as.ejb3.component.EJBComponentDescription)7 ArrayList (java.util.ArrayList)5 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)5 ViewConfiguration (org.jboss.as.ee.component.ViewConfiguration)5 ViewDescription (org.jboss.as.ee.component.ViewDescription)5 WriteReplaceInterface (org.jboss.as.ee.component.serialization.WriteReplaceInterface)5 EJBViewDescription (org.jboss.as.ejb3.component.EJBViewDescription)5 ImmediateInterceptorFactory (org.jboss.invocation.ImmediateInterceptorFactory)5 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 ViewConfigurator (org.jboss.as.ee.component.ViewConfigurator)4 SessionBeanComponentDescription (org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)4