Search in sources :

Example 6 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)

Example 7 with EEModuleDescription

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

the class EEModuleInitialProcessor method deploy.

public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final String deploymentUnitName = deploymentUnit.getName();
    final String moduleName;
    if (deploymentUnitName.endsWith(".war") || deploymentUnitName.endsWith(".wab") || deploymentUnitName.endsWith(".jar") || deploymentUnitName.endsWith(".ear") || deploymentUnitName.endsWith(".rar")) {
        moduleName = deploymentUnitName.substring(0, deploymentUnitName.length() - 4);
    } else {
        moduleName = deploymentUnitName;
    }
    final String appName;
    final String earApplicationName = deploymentUnit.getAttachment(Attachments.EAR_APPLICATION_NAME);
    //if this is non-null this is always the one we want to use
    if (earApplicationName != null) {
        appName = earApplicationName;
    } else {
        //an appname of null means use the module name
        appName = null;
    }
    deploymentUnit.putAttachment(Attachments.EE_MODULE_DESCRIPTION, new EEModuleDescription(appName, moduleName, earApplicationName, appClient));
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 8 with EEModuleDescription

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

the class AbstractComponentConfigProcessor method deploy.

/**
     * {@inheritDoc} *
     */
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final Collection<ComponentDescription> componentConfigurations = eeModuleDescription.getComponentDescriptions();
    if (componentConfigurations == null || componentConfigurations.isEmpty()) {
        return;
    }
    for (ComponentDescription componentConfiguration : componentConfigurations) {
        final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
        if (index != null) {
            processComponentConfig(deploymentUnit, phaseContext, index, componentConfiguration);
        }
    }
}
Also used : ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 9 with EEModuleDescription

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

the class AbstractDeploymentDescriptorBindingsProcessor method deploy.

@Override
public final void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final DeploymentDescriptorEnvironment environment = deploymentUnit.getAttachment(Attachments.MODULE_DEPLOYMENT_DESCRIPTOR_ENVIRONMENT);
    final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
    final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    final DeploymentReflectionIndex deploymentReflectionIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
    final EEModuleDescription description = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    if (module == null || description == null) {
        return;
    }
    if (environment != null) {
        final List<BindingConfiguration> bindings = processDescriptorEntries(deploymentUnit, environment, description, null, module.getClassLoader(), deploymentReflectionIndex, applicationClasses);
        description.getBindingConfigurations().addAll(bindings);
    }
    for (final ComponentDescription componentDescription : description.getComponentDescriptions()) {
        if (componentDescription.getDeploymentDescriptorEnvironment() != null) {
            final List<BindingConfiguration> bindings = processDescriptorEntries(deploymentUnit, componentDescription.getDeploymentDescriptorEnvironment(), componentDescription, componentDescription, module.getClassLoader(), deploymentReflectionIndex, applicationClasses);
            componentDescription.getBindingConfigurations().addAll(bindings);
        }
    }
    for (final InterceptorEnvironment interceptorEnv : description.getInterceptorEnvironment().values()) {
        final List<BindingConfiguration> bindings = processDescriptorEntries(deploymentUnit, interceptorEnv.getDeploymentDescriptorEnvironment(), interceptorEnv, null, module.getClassLoader(), deploymentReflectionIndex, applicationClasses);
        interceptorEnv.getBindingConfigurations().addAll(bindings);
    }
}
Also used : ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) DeploymentDescriptorEnvironment(org.jboss.as.ee.component.DeploymentDescriptorEnvironment) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex) BindingConfiguration(org.jboss.as.ee.component.BindingConfiguration) InterceptorEnvironment(org.jboss.as.ee.component.InterceptorEnvironment)

Example 10 with EEModuleDescription

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

the class ApplicationClassesAggregationProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final List<EEModuleDescription> descriptions = new ArrayList<EEModuleDescription>();
    for (final DeploymentUnit visibleDeployment : deploymentUnit.getAttachmentList(org.jboss.as.server.deployment.Attachments.ACCESSIBLE_SUB_DEPLOYMENTS)) {
        final EEModuleDescription description = visibleDeployment.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
        if (description != null) {
            descriptions.add(description);
        }
    }
    final EEApplicationClasses classes = new EEApplicationClasses(descriptions);
    deploymentUnit.putAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION, classes);
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) ArrayList(java.util.ArrayList) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

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