Search in sources :

Example 1 with DelegatingSupplier

use of org.jboss.as.server.deployment.DelegatingSupplier in project wildfly by wildfly.

the class GlobalDirectoryDependencyProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ServiceName depUnitServiceName = deploymentUnit.getServiceName();
    final DeploymentUnit parent = deploymentUnit.getParent();
    final DeploymentUnit topLevelDeployment = parent == null ? deploymentUnit : parent;
    final ExternalModule externalModuleService = topLevelDeployment.getAttachment(Attachments.EXTERNAL_MODULE_SERVICE);
    final ModuleLoader moduleLoader = deploymentUnit.getAttachment(Attachments.SERVICE_MODULE_LOADER);
    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    final CapabilityServiceSupport capabilitySupport = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
    final ServiceRegistry serviceRegistry = phaseContext.getServiceRegistry();
    final ServiceTarget target = phaseContext.getServiceTarget();
    final ServiceTarget externalServiceTarget = deploymentUnit.getAttachment(Attachments.EXTERNAL_SERVICE_TARGET);
    final ServiceName allDirReadyServiceName = depUnitServiceName.append("directory-services-ready");
    final ServiceBuilder<?> allDirReadyServiceBuilder = target.addService(allDirReadyServiceName);
    final List<Supplier<GlobalDirectoryResourceDefinition.GlobalDirectory>> allDirReadySuppliers = new ArrayList<>();
    final ServiceName csName = capabilitySupport.getCapabilityServiceName(EE_GLOBAL_DIRECTORY_CAPABILITY_NAME);
    List<ServiceName> serviceNames = serviceRegistry.getServiceNames();
    for (ServiceName serviceName : serviceNames) {
        if (csName.isParentOf(serviceName)) {
            Supplier<GlobalDirectoryResourceDefinition.GlobalDirectory> pathRequirement = allDirReadyServiceBuilder.requires(serviceName);
            allDirReadySuppliers.add(pathRequirement);
        }
    }
    if (!allDirReadySuppliers.isEmpty()) {
        GlobalDirectoryDeploymentService globalDirDepService = new GlobalDirectoryDeploymentService(allDirReadySuppliers, externalModuleService, moduleSpecification, moduleLoader, serviceRegistry, externalServiceTarget);
        allDirReadyServiceBuilder.requires(phaseContext.getPhaseServiceName());
        allDirReadyServiceBuilder.setInstance(globalDirDepService).install();
        phaseContext.requires(allDirReadyServiceName, new DelegatingSupplier());
    }
}
Also used : ModuleLoader(org.jboss.modules.ModuleLoader) ServiceTarget(org.jboss.msc.service.ServiceTarget) ArrayList(java.util.ArrayList) GlobalDirectoryDeploymentService(org.jboss.as.ee.subsystem.GlobalDirectoryDeploymentService) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) DelegatingSupplier(org.jboss.as.server.deployment.DelegatingSupplier) ServiceName(org.jboss.msc.service.ServiceName) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) GlobalDirectoryResourceDefinition(org.jboss.as.ee.subsystem.GlobalDirectoryResourceDefinition) DelegatingSupplier(org.jboss.as.server.deployment.DelegatingSupplier) Supplier(java.util.function.Supplier) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ExternalModule(org.jboss.as.server.moduleservice.ExternalModule) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

ArrayList (java.util.ArrayList)1 Supplier (java.util.function.Supplier)1 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)1 GlobalDirectoryDeploymentService (org.jboss.as.ee.subsystem.GlobalDirectoryDeploymentService)1 GlobalDirectoryResourceDefinition (org.jboss.as.ee.subsystem.GlobalDirectoryResourceDefinition)1 DelegatingSupplier (org.jboss.as.server.deployment.DelegatingSupplier)1 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 ModuleSpecification (org.jboss.as.server.deployment.module.ModuleSpecification)1 ExternalModule (org.jboss.as.server.moduleservice.ExternalModule)1 ModuleLoader (org.jboss.modules.ModuleLoader)1 ServiceName (org.jboss.msc.service.ServiceName)1 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1