Search in sources :

Example 1 with ServiceComponentInstantiator

use of org.jboss.as.service.component.ServiceComponentInstantiator in project wildfly by wildfly.

the class ParsedServiceDeploymentProcessor method deploy.

/**
     * Process a deployment for JbossService configuration.  Will install a {@code JBossService} for each configured service.
     *
     * @param phaseContext the deployment unit context
     * @throws DeploymentUnitProcessingException
     */
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final JBossServiceXmlDescriptor serviceXmlDescriptor = deploymentUnit.getAttachment(JBossServiceXmlDescriptor.ATTACHMENT_KEY);
    if (serviceXmlDescriptor == null) {
        // Skip deployments without a service xml descriptor
        return;
    }
    // assert module
    final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
    if (module == null)
        throw SarLogger.ROOT_LOGGER.failedToGetAttachment("module", deploymentUnit);
    // assert reflection index
    final DeploymentReflectionIndex reflectionIndex = deploymentUnit.getAttachment(Attachments.REFLECTION_INDEX);
    if (reflectionIndex == null)
        throw SarLogger.ROOT_LOGGER.failedToGetAttachment("reflection index", deploymentUnit);
    // install services
    final ClassLoader classLoader = module.getClassLoader();
    final List<JBossServiceConfig> serviceConfigs = serviceXmlDescriptor.getServiceConfigs();
    final ServiceTarget target = phaseContext.getServiceTarget();
    final Map<String, ServiceComponentInstantiator> serviceComponents = deploymentUnit.getAttachment(ServiceAttachments.SERVICE_COMPONENT_INSTANTIATORS);
    for (final JBossServiceConfig serviceConfig : serviceConfigs) {
        addServices(target, serviceConfig, classLoader, reflectionIndex, serviceComponents != null ? serviceComponents.get(serviceConfig.getName()) : null, phaseContext);
    }
}
Also used : JBossServiceXmlDescriptor(org.jboss.as.service.descriptor.JBossServiceXmlDescriptor) ServiceTarget(org.jboss.msc.service.ServiceTarget) JBossServiceConfig(org.jboss.as.service.descriptor.JBossServiceConfig) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex) ServiceComponentInstantiator(org.jboss.as.service.component.ServiceComponentInstantiator)

Aggregations

DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)1 ServiceComponentInstantiator (org.jboss.as.service.component.ServiceComponentInstantiator)1 JBossServiceConfig (org.jboss.as.service.descriptor.JBossServiceConfig)1 JBossServiceXmlDescriptor (org.jboss.as.service.descriptor.JBossServiceXmlDescriptor)1 Module (org.jboss.modules.Module)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1