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();
}
Aggregations