Search in sources :

Example 11 with ComponentDescription

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

the class EjbDependsOnMergingProcessor method setupDependencies.

private void setupDependencies(final EJBComponentDescription description, final EEApplicationDescription applicationDescription, final ResourceRoot deploymentRoot, final String[] annotationValues) throws DeploymentUnitProcessingException {
    for (final String annotationValue : annotationValues) {
        final Set<ComponentDescription> components = applicationDescription.getComponents(annotationValue, deploymentRoot.getRoot());
        if (components.isEmpty()) {
            throw EjbLogger.ROOT_LOGGER.failToFindEjbRefByDependsOn(annotationValue, description.getComponentClassName());
        } else if (components.size() != 1) {
            throw EjbLogger.ROOT_LOGGER.failToCallEjbRefByDependsOn(annotationValue, description.getComponentClassName(), components);
        }
        final ComponentDescription component = components.iterator().next();
        description.addDependency(component.getStartServiceName(), DependencyType.REQUIRED);
        if (description instanceof SingletonComponentDescription) {
            ((SingletonComponentDescription) description).getDependsOn().add(component.getStartServiceName());
            if (ROOT_LOGGER.isDebugEnabled()) {
                ROOT_LOGGER.debugf(description.getEJBName() + " bean is dependent on " + component.getComponentName());
            }
        }
    }
}
Also used : SingletonComponentDescription(org.jboss.as.ejb3.component.singleton.SingletonComponentDescription) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) SingletonComponentDescription(org.jboss.as.ejb3.component.singleton.SingletonComponentDescription)

Example 12 with ComponentDescription

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

the class InterceptorAnnotationProcessor 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 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);
    if (MetadataCompleteMarker.isMetadataComplete(deploymentUnit)) {
        return;
    }
    if (componentConfigurations == null || componentConfigurations.isEmpty()) {
        return;
    }
    for (final ComponentDescription description : componentConfigurations) {
        processComponentConfig(applicationClasses, deploymentReflectionIndex, description, deploymentUnit);
    }
}
Also used : ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)

Example 13 with ComponentDescription

use of org.jboss.as.ee.component.ComponentDescription 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 14 with ComponentDescription

use of org.jboss.as.ee.component.ComponentDescription 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 15 with ComponentDescription

use of org.jboss.as.ee.component.ComponentDescription 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)

Aggregations

ComponentDescription (org.jboss.as.ee.component.ComponentDescription)65 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)45 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)44 ServiceName (org.jboss.msc.service.ServiceName)20 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)19 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)18 Module (org.jboss.modules.Module)18 EJBComponentDescription (org.jboss.as.ejb3.component.EJBComponentDescription)17 ComponentConfigurator (org.jboss.as.ee.component.ComponentConfigurator)16 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)16 SessionBeanComponentDescription (org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)15 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)11 HashMap (java.util.HashMap)10 HashSet (java.util.HashSet)9 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)9 ServiceTarget (org.jboss.msc.service.ServiceTarget)9 ImmediateInterceptorFactory (org.jboss.invocation.ImmediateInterceptorFactory)8 BindingConfiguration (org.jboss.as.ee.component.BindingConfiguration)5 DependencyConfigurator (org.jboss.as.ee.component.DependencyConfigurator)5 InterceptorDescription (org.jboss.as.ee.component.InterceptorDescription)5