if (rootBda == null) {
WeldLogger.ROOT_LOGGER.couldNotFindBeanManagerForDeployment(deploymentUnit.getName());
return;
}
final ServiceName weldServiceName = topLevelDeployment.getServiceName().append(WeldService.SERVICE_NAME);
// add the BeanManager service
final ServiceName beanManagerServiceName = BeanManagerService.serviceName(deploymentUnit);
BeanManagerService beanManagerService = new BeanManagerService(rootBda.getId());
serviceTarget.addService(beanManagerServiceName, beanManagerService).addDependency(weldServiceName,
WeldContainer.class, beanManagerService.getWeldContainer()).install();
final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
if (moduleDescription == null) {
return;
}
//hack to set up a java:comp binding for jar deployments as well as wars
if (DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit) || deploymentUnit.getName().endsWith(".jar")) {
// bind the bean manager to JNDI
final ServiceName moduleContextServiceName = ContextNames.contextServiceNameOfModule(moduleDescription.getApplicationName(), moduleDescription.getModuleName());
bindBeanManager(serviceTarget, beanManagerServiceName, moduleContextServiceName, dependencies);
}
//bind the bm into java:comp for all components that require it
for (ComponentDescription component : moduleDescription.getComponentDescriptions()) {
if (component.getNamingMode() == ComponentNamingMode.CREATE) {
final ServiceName compContextServiceName = ContextNames.contextServiceNameOfComponent(moduleDescription.getApplicationName(), moduleDescription.getModuleName(), component.getComponentName());
bindBeanManager(serviceTarget, beanManagerServiceName, compContextServiceName, dependencies);
}
}
deploymentUnit.addToAttachmentList(Attachments.SETUP_ACTIONS, new WeldContextSetup());
}