Search in sources :

Example 1 with EEModuleConfiguration

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

the class EjbManagementDeploymentUnitProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleConfiguration moduleDescription = deploymentUnit.getAttachment(EE_MODULE_CONFIGURATION);
    if (moduleDescription == null) {
        // Nothing to do
        return;
    }
    if (deploymentUnit.getParent() != null && deploymentUnit.getParent().getParent() != null) {
        // We only expose management resources 2 levels deep
        return;
    }
    // Iterate through each component, installing it into the container
    for (final ComponentConfiguration configuration : moduleDescription.getComponentConfigurations()) {
        try {
            final ComponentDescription componentDescription = configuration.getComponentDescription();
            if (componentDescription instanceof EJBComponentDescription) {
                installManagementResource(configuration, deploymentUnit);
            }
        } catch (RuntimeException e) {
            throw EjbLogger.ROOT_LOGGER.failedToInstallManagementResource(e, configuration.getComponentName());
        }
    }
}
Also used : ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EEModuleConfiguration(org.jboss.as.ee.component.EEModuleConfiguration) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription)

Example 2 with EEModuleConfiguration

use of org.jboss.as.ee.component.EEModuleConfiguration 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 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 (Throwable 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) 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 3 with EEModuleConfiguration

use of org.jboss.as.ee.component.EEModuleConfiguration 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) {
        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);
    }
    // now we need to process resource bindings that are not part of a component
    // we don't process app client modules, as it just causes problems by installing bindings that
    // were only intended to be installed when running as an app client
    boolean appClient = DeploymentTypeMarker.isType(DeploymentType.APPLICATION_CLIENT, deploymentUnit) || this.appclient;
    if (!ignoreUnusedResourceBinding && !MetadataCompleteMarker.isMetadataComplete(phaseContext.getDeploymentUnit()) && !appClient) {
        final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
        for (EEModuleClassDescription config : eeModuleDescription.getClassDescriptions()) {
            if (handledClasses.contains(config.getClassName())) {
                continue;
            }
            if (config.isInvalid()) {
                continue;
            }
            final Set<BindingConfiguration> classLevelBindings = new HashSet<>(config.getBindingConfigurations());
            // between classes and not miss out on any.)
            if (!classLevelBindings.isEmpty()) {
                ClassInfo classInfo = index.getClassByName(DotName.createSimple(config.getClassName()));
                if (!isConcreteClass(classInfo) && !hasConcreteSubclass(index, classInfo)) {
                    continue;
                }
            }
            for (BindingConfiguration binding : classLevelBindings) {
                final String bindingName = binding.getName();
                final boolean compBinding = bindingName.startsWith("java:comp") || !bindingName.startsWith("java:");
                if (compBinding && !DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
                    // we don't have a comp namespace
                    continue;
                }
                final ContextNames.BindInfo bindInfo = ContextNames.bindInfoForEnvEntry(moduleConfiguration.getApplicationName(), moduleConfiguration.getModuleName(), null, false, binding.getName());
                if (deploymentDescriptorBindings.containsKey(bindInfo.getBinderServiceName())) {
                    // this has been overridden by a DD binding
                    continue;
                }
                ROOT_LOGGER.tracef("Binding %s using service %s", binding.getName(), bindInfo.getBinderServiceName());
                addJndiBinding(moduleConfiguration, binding, phaseContext, dependencies);
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) InterceptorDescription(org.jboss.as.ee.component.InterceptorDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ContextInjectionSource(org.jboss.as.ee.naming.ContextInjectionSource) BindingConfiguration(org.jboss.as.ee.component.BindingConfiguration) ContextNames(org.jboss.as.naming.deployment.ContextNames) HashSet(java.util.HashSet) EEModuleConfiguration(org.jboss.as.ee.component.EEModuleConfiguration) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) ServiceName(org.jboss.msc.service.ServiceName) EEModuleClassDescription(org.jboss.as.ee.component.EEModuleClassDescription) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) ClassInfo(org.jboss.jandex.ClassInfo)

Example 4 with EEModuleConfiguration

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

the class ComponentInstallProcessor method deploy.

public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final Module module = deploymentUnit.getAttachment(MODULE);
    final EEModuleConfiguration moduleConfiguration = deploymentUnit.getAttachment(EE_MODULE_CONFIGURATION);
    if (module == null || moduleConfiguration == null) {
        return;
    }
    ComponentRegistry componentRegistry = deploymentUnit.getAttachment(COMPONENT_REGISTRY);
    final List<ServiceName> dependencies = deploymentUnit.getAttachmentList(org.jboss.as.server.deployment.Attachments.JNDI_DEPENDENCIES);
    final ServiceName bindingDependencyService = JndiNamingDependencyProcessor.serviceName(deploymentUnit.getServiceName());
    // Iterate through each component, installing it into the container
    for (final ComponentConfiguration configuration : moduleConfiguration.getComponentConfigurations()) {
        try {
            ROOT_LOGGER.tracef("Installing component %s", configuration.getComponentClass().getName());
            deployComponent(phaseContext, configuration, dependencies, bindingDependencyService);
            componentRegistry.addComponent(configuration);
            // we need to make sure that the web deployment has a dependency on all components it the app, so web components are started
            // when the web subsystem is starting
            // we only add a dependency on components in the same sub deployment, otherwise we get circular dependencies when initialize-in-order is used
            deploymentUnit.addToAttachmentList(org.jboss.as.server.deployment.Attachments.WEB_DEPENDENCIES, configuration.getComponentDescription().getStartServiceName());
        } catch (Exception e) {
            throw EeLogger.ROOT_LOGGER.failedToInstallComponent(e, configuration.getComponentName());
        }
    }
}
Also used : ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) ComponentRegistry(org.jboss.as.ee.component.ComponentRegistry) ServiceName(org.jboss.msc.service.ServiceName) EEModuleConfiguration(org.jboss.as.ee.component.EEModuleConfiguration) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) CircularDependencyException(org.jboss.msc.service.CircularDependencyException) DuplicateServiceException(org.jboss.msc.service.DuplicateServiceException) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException)

Example 5 with EEModuleConfiguration

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

the class MdbDeliveryDependenciesProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleConfiguration moduleConfiguration = deploymentUnit.getAttachment(EE_MODULE_CONFIGURATION);
    if (moduleConfiguration == null) {
        return;
    }
    // support for using capabilities to resolve service names
    CapabilityServiceSupport capabilityServiceSupport = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.CAPABILITY_SERVICE_SUPPORT);
    final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
    boolean clusteredSingletonFound = false;
    for (final ComponentConfiguration configuration : moduleConfiguration.getComponentConfigurations()) {
        ComponentDescription description = configuration.getComponentDescription();
        if (description instanceof MessageDrivenComponentDescription) {
            final MessageDrivenComponentDescription mdbDescription = (MessageDrivenComponentDescription) description;
            if (mdbDescription.isDeliveryControlled()) {
                final MdbDeliveryControllerService mdbDeliveryControllerService = new MdbDeliveryControllerService();
                final ServiceBuilder<MdbDeliveryControllerService> builder = serviceTarget.addService(mdbDescription.getDeliveryControllerName(), mdbDeliveryControllerService).addDependency(description.getCreateServiceName(), MessageDrivenComponent.class, mdbDeliveryControllerService.getMdbComponent()).setInitialMode(Mode.PASSIVE);
                if (mdbDescription.isClusteredSingleton()) {
                    clusteredSingletonFound = true;
                    builder.requires(CLUSTERED_SINGLETON_CAPABILITY.getCapabilityServiceName());
                    builder.addDependency(CLUSTERED_SINGLETON_CAPABILITY.getCapabilityServiceName());
                }
                if (mdbDescription.getDeliveryGroups() != null) {
                    for (String deliveryGroup : mdbDescription.getDeliveryGroups()) {
                        final ServiceName deliveryGroupServiceName = capabilityServiceSupport.getCapabilityServiceName(MDB_DELIVERY_GROUP_CAPABILITY_NAME, deliveryGroup);
                        if (phaseContext.getServiceRegistry().getService(deliveryGroupServiceName) == null) {
                            throw EjbLogger.DEPLOYMENT_LOGGER.missingMdbDeliveryGroup(deliveryGroup);
                        }
                        builder.addDependency(deliveryGroupServiceName);
                    }
                }
                builder.install();
            }
        }
    }
    if (clusteredSingletonFound) {
        // Add dependency on the singleton barrier, which starts on-demand
        // (the MDB delivery controller won't demand the singleton barrier service to start)
        serviceTarget.addDependency(SingletonBarrierService.SERVICE_NAME);
    }
}
Also used : MessageDrivenComponentDescription(org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) MessageDrivenComponent(org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponent) ServiceTarget(org.jboss.msc.service.ServiceTarget) EEModuleConfiguration(org.jboss.as.ee.component.EEModuleConfiguration) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) MdbDeliveryControllerService(org.jboss.as.ejb3.component.messagedriven.MdbDeliveryControllerService) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) MessageDrivenComponentDescription(org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription) ServiceName(org.jboss.msc.service.ServiceName) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)6 EEModuleConfiguration (org.jboss.as.ee.component.EEModuleConfiguration)6 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)5 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)4 ServiceName (org.jboss.msc.service.ServiceName)4 Module (org.jboss.modules.Module)3 HashSet (java.util.HashSet)2 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)2 MessageDrivenComponentDescription (org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription)2 HashMap (java.util.HashMap)1 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)1 BindingConfiguration (org.jboss.as.ee.component.BindingConfiguration)1 ComponentConfigurator (org.jboss.as.ee.component.ComponentConfigurator)1 ComponentRegistry (org.jboss.as.ee.component.ComponentRegistry)1 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)1 EEModuleClassDescription (org.jboss.as.ee.component.EEModuleClassDescription)1 InterceptorDescription (org.jboss.as.ee.component.InterceptorDescription)1 ContextInjectionSource (org.jboss.as.ee.naming.ContextInjectionSource)1 EJBComponentDescription (org.jboss.as.ejb3.component.EJBComponentDescription)1 MdbDeliveryControllerService (org.jboss.as.ejb3.component.messagedriven.MdbDeliveryControllerService)1