Search in sources :

Example 1 with WeldStartCompletionService

use of org.jboss.as.weld.WeldStartCompletionService in project wildfly by wildfly.

the class WeldDeploymentCleanupProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final DeploymentUnit parent = Utils.getRootDeploymentUnit(deploymentUnit);
    final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
    final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
    // obtain service names
    ServiceName weldStartCompletionServiceName = parent.getServiceName().append(WeldStartCompletionService.SERVICE_NAME);
    ServiceName weldBootstrapServiceName = parent.getServiceName().append(WeldBootstrapService.SERVICE_NAME);
    ServiceName weldStartServiceName = parent.getServiceName().append(WeldStartService.SERVICE_NAME);
    // if it is not Weld deployment, we skip it
    if (!WeldDeploymentMarker.isPartOfWeldDeployment(deploymentUnit)) {
        return;
    }
    // only register this on top level deployments
    if (deploymentUnit.getParent() != null) {
        return;
    }
    // add dependency on our WeldBootstrapService and WeldStartService to ensure this goes after them
    ServiceBuilder<?> weldStartCompletionServiceBuilder = serviceTarget.addService(weldStartCompletionServiceName);
    final Supplier<WeldBootstrapService> bootstrapSupplier = weldStartCompletionServiceBuilder.requires(weldBootstrapServiceName);
    weldStartCompletionServiceBuilder.requires(weldStartServiceName);
    // require component start services from top level deployment
    for (ServiceName componentStartSN : getComponentStartServiceNames(deploymentUnit)) {
        weldStartCompletionServiceBuilder.requires(componentStartSN);
    }
    // require component start services from sub-deployments
    final List<DeploymentUnit> subDeployments = deploymentUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS);
    for (DeploymentUnit sub : subDeployments) {
        ServiceRegistry registry = sub.getServiceRegistry();
        List<ServiceName> componentStartServiceNames = getComponentStartServiceNames(sub);
        for (ServiceName componentStartSN : componentStartServiceNames) {
            weldStartCompletionServiceBuilder.requires(componentStartSN);
        }
    }
    weldStartCompletionServiceBuilder.setInstance(new WeldStartCompletionService(bootstrapSupplier, WeldDeploymentProcessor.getSetupActions(deploymentUnit), module.getClassLoader()));
    weldStartCompletionServiceBuilder.install();
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) WeldStartCompletionService(org.jboss.as.weld.WeldStartCompletionService) ServiceTarget(org.jboss.msc.service.ServiceTarget) WeldBootstrapService(org.jboss.as.weld.WeldBootstrapService) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 WeldBootstrapService (org.jboss.as.weld.WeldBootstrapService)1 WeldStartCompletionService (org.jboss.as.weld.WeldStartCompletionService)1 Module (org.jboss.modules.Module)1 ServiceName (org.jboss.msc.service.ServiceName)1 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1