Search in sources :

Example 16 with EEModuleDescription

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

the class LifecycleAnnotationParsingProcessor method deploy.

public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
    final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
    for (DotName annotationName : LIFE_CYCLE_ANNOTATIONS) {
        final List<AnnotationInstance> lifecycles = index.getAnnotations(annotationName);
        for (AnnotationInstance annotation : lifecycles) {
            processLifeCycle(eeModuleDescription, annotation.target(), annotationName, applicationClasses);
        }
    }
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DotName(org.jboss.jandex.DotName) AnnotationInstance(org.jboss.jandex.AnnotationInstance)

Example 17 with EEModuleDescription

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

the class ModuleJndiBindingProcessor method deploy.

public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
    final EEModuleConfiguration moduleConfiguration = deploymentUnit.getAttachment(Attachments.EE_MODULE_CONFIGURATION);
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    if (moduleConfiguration == null || DeploymentUtils.skipRepeatedActivation(deploymentUnit, 0)) {
        return;
    }
    final List<ServiceName> dependencies = deploymentUnit.getAttachmentList(org.jboss.as.server.deployment.Attachments.JNDI_DEPENDENCIES);
    final Map<ServiceName, BindingConfiguration> deploymentDescriptorBindings = new HashMap<ServiceName, BindingConfiguration>();
    final List<BindingConfiguration> bindingConfigurations = eeModuleDescription.getBindingConfigurations();
    //we need to make sure that java:module/env and java:comp/env are always available
    if (!DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
        bindingConfigurations.add(new BindingConfiguration("java:module/env", new ContextInjectionSource("env", "java:module/env")));
    }
    if (deploymentUnit.getParent() == null) {
        bindingConfigurations.add(new BindingConfiguration("java:app/env", new ContextInjectionSource("env", "java:app/env")));
    }
    for (BindingConfiguration binding : bindingConfigurations) {
        final ContextNames.BindInfo bindInfo = ContextNames.bindInfoForEnvEntry(moduleConfiguration.getApplicationName(), moduleConfiguration.getModuleName(), null, false, binding.getName());
        deploymentDescriptorBindings.put(bindInfo.getBinderServiceName(), binding);
        addJndiBinding(moduleConfiguration, binding, phaseContext, dependencies);
    }
    // these are bindings that have been added via a deployment descriptor
    for (final ComponentConfiguration componentConfiguration : moduleConfiguration.getComponentConfigurations()) {
        // handle these duplicates?
        for (BindingConfiguration binding : componentConfiguration.getComponentDescription().getBindingConfigurations()) {
            final String bindingName = binding.getName();
            final boolean compBinding = bindingName.startsWith("java:comp") || !bindingName.startsWith("java:");
            if (componentConfiguration.getComponentDescription().getNamingMode() == ComponentNamingMode.CREATE && compBinding) {
                //components with there own comp context do their own binding
                continue;
            }
            final ContextNames.BindInfo bindInfo = ContextNames.bindInfoForEnvEntry(moduleConfiguration.getApplicationName(), moduleConfiguration.getModuleName(), null, false, binding.getName());
            deploymentDescriptorBindings.put(bindInfo.getBinderServiceName(), binding);
            addJndiBinding(moduleConfiguration, binding, phaseContext, dependencies);
        }
    }
    //now add all class level bindings
    final Set<String> handledClasses = new HashSet<String>();
    for (final ComponentConfiguration componentConfiguration : moduleConfiguration.getComponentConfigurations()) {
        final Set<Class<?>> classConfigurations = new HashSet<Class<?>>();
        classConfigurations.add(componentConfiguration.getComponentClass());
        for (final InterceptorDescription interceptor : componentConfiguration.getComponentDescription().getAllInterceptors()) {
            try {
                classConfigurations.add(ClassLoadingUtils.loadClass(interceptor.getInterceptorClassName(), module));
            } catch (ClassNotFoundException e) {
                throw EeLogger.ROOT_LOGGER.cannotLoadInterceptor(e, interceptor.getInterceptorClassName(), componentConfiguration.getComponentClass());
            }
        }
        processClassConfigurations(phaseContext, applicationClasses, moduleConfiguration, deploymentDescriptorBindings, handledClasses, componentConfiguration.getComponentDescription().getNamingMode(), classConfigurations, componentConfiguration.getComponentName(), dependencies);
    }
}
Also used : HashMap(java.util.HashMap) EEModuleConfiguration(org.jboss.as.ee.component.EEModuleConfiguration) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) InterceptorDescription(org.jboss.as.ee.component.InterceptorDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) ServiceName(org.jboss.msc.service.ServiceName) ContextInjectionSource(org.jboss.as.ee.naming.ContextInjectionSource) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) BindingConfiguration(org.jboss.as.ee.component.BindingConfiguration) ContextNames(org.jboss.as.naming.deployment.ContextNames) HashSet(java.util.HashSet)

Example 18 with EEModuleDescription

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

the class ResourceInjectionAnnotationParsingProcessor method deploy.

public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
    final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
    final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    final PropertyReplacer replacer = EJBAnnotationPropertyReplacement.propertyReplacer(deploymentUnit);
    if (module == null) {
        return;
    }
    final List<AnnotationInstance> resourceAnnotations = index.getAnnotations(RESOURCE_ANNOTATION_NAME);
    for (AnnotationInstance annotation : resourceAnnotations) {
        final AnnotationTarget annotationTarget = annotation.target();
        final AnnotationValue nameValue = annotation.value("name");
        final String name = (nameValue != null) ? replacer.replaceProperties(nameValue.asString()) : null;
        final AnnotationValue typeValue = annotation.value("type");
        final String type = typeValue != null ? typeValue.asClass().name().toString() : null;
        if (annotationTarget instanceof FieldInfo) {
            final FieldInfo fieldInfo = (FieldInfo) annotationTarget;
            final ClassInfo classInfo = fieldInfo.declaringClass();
            EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
            processFieldResource(phaseContext, fieldInfo, name, type, classDescription, annotation, eeModuleDescription, module, applicationClasses, replacer);
        } else if (annotationTarget instanceof MethodInfo) {
            final MethodInfo methodInfo = (MethodInfo) annotationTarget;
            ClassInfo classInfo = methodInfo.declaringClass();
            EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
            processMethodResource(phaseContext, methodInfo, name, type, classDescription, annotation, eeModuleDescription, module, applicationClasses, replacer);
        } else if (annotationTarget instanceof ClassInfo) {
            final ClassInfo classInfo = (ClassInfo) annotationTarget;
            EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
            processClassResource(phaseContext, name, type, classDescription, annotation, eeModuleDescription, module, applicationClasses, replacer);
        }
    }
    final List<AnnotationInstance> resourcesAnnotations = index.getAnnotations(RESOURCES_ANNOTATION_NAME);
    for (AnnotationInstance outerAnnotation : resourcesAnnotations) {
        final AnnotationTarget annotationTarget = outerAnnotation.target();
        if (annotationTarget instanceof ClassInfo) {
            final ClassInfo classInfo = (ClassInfo) annotationTarget;
            final AnnotationInstance[] values = outerAnnotation.value("value").asNestedArray();
            for (AnnotationInstance annotation : values) {
                final AnnotationValue nameValue = annotation.value("name");
                final String name = (nameValue != null) ? replacer.replaceProperties(nameValue.asString()) : null;
                final AnnotationValue typeValue = annotation.value("type");
                final String type = (typeValue != null) ? typeValue.asClass().name().toString() : null;
                EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
                processClassResource(phaseContext, name, type, classDescription, annotation, eeModuleDescription, module, applicationClasses, replacer);
            }
        }
    }
}
Also used : AnnotationTarget(org.jboss.jandex.AnnotationTarget) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) AnnotationValue(org.jboss.jandex.AnnotationValue) PropertyReplacer(org.jboss.metadata.property.PropertyReplacer) MethodInfo(org.jboss.jandex.MethodInfo) EEModuleClassDescription(org.jboss.as.ee.component.EEModuleClassDescription) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) AnnotationInstance(org.jboss.jandex.AnnotationInstance) FieldInfo(org.jboss.jandex.FieldInfo) ClassInfo(org.jboss.jandex.ClassInfo)

Example 19 with EEModuleDescription

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

the class DescriptorEnvironmentLifecycleMethodProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
    final DeploymentDescriptorEnvironment environment = deploymentUnit.getAttachment(Attachments.MODULE_DEPLOYMENT_DESCRIPTOR_ENVIRONMENT);
    if (environment != null) {
        handleMethods(environment, eeModuleDescription, null);
    }
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) DeploymentDescriptorEnvironment(org.jboss.as.ee.component.DeploymentDescriptorEnvironment) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 20 with EEModuleDescription

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

the class EEModuleConfigurationProcessor method deploy.

public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    final DeploymentReflectionIndex reflectionIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
    if (module == null || moduleDescription == null) {
        return;
    }
    final int startupBeansCount = moduleDescription.getStartupBeansCount();
    if (deploymentUnit.getParent() == null) {
        deploymentUnit.putAttachment(Attachments.STARTUP_COUNTDOWN, new StartupCountdown(startupBeansCount));
    } else {
        final StartupCountdown countdown = deploymentUnit.getParent().getAttachment(Attachments.STARTUP_COUNTDOWN);
        // copy ref to child deployment
        deploymentUnit.putAttachment(Attachments.STARTUP_COUNTDOWN, countdown);
        countdown.countUp(startupBeansCount);
    }
    final Set<ServiceName> failed = new HashSet<ServiceName>();
    final EEModuleConfiguration moduleConfiguration = new EEModuleConfiguration(moduleDescription);
    deploymentUnit.putAttachment(Attachments.EE_MODULE_CONFIGURATION, moduleConfiguration);
    final ClassLoader oldCl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
    try {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(module.getClassLoader());
        final Iterator<ComponentDescription> iterator = moduleDescription.getComponentDescriptions().iterator();
        while (iterator.hasNext()) {
            final ComponentDescription componentDescription = iterator.next();
            ROOT_LOGGER.debugf("Configuring component class: %s named %s", componentDescription.getComponentClassName(), componentDescription.getComponentName());
            final ComponentConfiguration componentConfiguration;
            try {
                componentConfiguration = componentDescription.createConfiguration(reflectionIndex.getClassIndex(ClassLoadingUtils.loadClass(componentDescription.getComponentClassName(), module)), module.getClassLoader(), module.getModuleLoader());
                for (final ComponentConfigurator componentConfigurator : componentDescription.getConfigurators()) {
                    componentConfigurator.configure(phaseContext, componentDescription, componentConfiguration);
                }
                moduleConfiguration.addComponentConfiguration(componentConfiguration);
            } catch (Exception e) {
                if (componentDescription.isOptional()) {
                    // https://issues.jboss.org/browse/WFLY-924 Just log a WARN summary of which component failed and then log the cause at DEBUG level
                    ROOT_LOGGER.componentInstallationFailure(componentDescription.getComponentName());
                    ROOT_LOGGER.debugf(e, "Not installing optional component %s due to an exception", componentDescription.getComponentName());
                    // keep track of failed optional components
                    failed.add(componentDescription.getStartServiceName());
                    failed.add(componentDescription.getCreateServiceName());
                    failed.add(componentDescription.getServiceName());
                    iterator.remove();
                } else {
                    throw EeLogger.ROOT_LOGGER.cannotConfigureComponent(e, componentDescription.getComponentName());
                }
            }
        }
        deploymentUnit.putAttachment(Attachments.FAILED_COMPONENTS, Collections.synchronizedSet(failed));
    } finally {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldCl);
    }
}
Also used : ComponentDescription(org.jboss.as.ee.component.ComponentDescription) ComponentConfigurator(org.jboss.as.ee.component.ComponentConfigurator) EEModuleConfiguration(org.jboss.as.ee.component.EEModuleConfiguration) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ServiceName(org.jboss.msc.service.ServiceName) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex) HashSet(java.util.HashSet)

Aggregations

EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)90 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)77 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)44 Module (org.jboss.modules.Module)27 ServiceName (org.jboss.msc.service.ServiceName)21 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)18 CompositeIndex (org.jboss.as.server.deployment.annotation.CompositeIndex)17 EJBComponentDescription (org.jboss.as.ejb3.component.EJBComponentDescription)16 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)16 HashSet (java.util.HashSet)14 HashMap (java.util.HashMap)11 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)11 BindingConfiguration (org.jboss.as.ee.component.BindingConfiguration)10 SessionBeanComponentDescription (org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)10 ServiceTarget (org.jboss.msc.service.ServiceTarget)10 AnnotationInstance (org.jboss.jandex.AnnotationInstance)9 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)8 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)8 EjbJarMetaData (org.jboss.metadata.ejb.spec.EjbJarMetaData)7 Map (java.util.Map)6