List<BeanDeploymentModule> additionalModules = subDeployment.getAttachmentList(WeldAttachments.VISIBLE_ADDITIONAL_BEAN_DEPLOYMENT_MODULE);
moduleSpecByIdentifier.put(subDeploymentModule.getIdentifier(), subDeploymentModuleSpec);
//we have to do this here as the aggregate components are not available in earlier phases
final ResourceRoot subDeploymentRoot = subDeployment.getAttachment(Attachments.DEPLOYMENT_ROOT);
final EjbInjectionServices ejbInjectionServices = new WeldEjbInjectionServices(deploymentUnit.getServiceRegistry(), eeModuleDescription, eeApplicationDescription, subDeploymentRoot.getRoot());
bdm.addService(EjbInjectionServices.class, ejbInjectionServices);
for(final BeanDeploymentModule additional : additionalModules) {
additional.addBeanDeploymentModule(bdm);
bdm.addBeanDeploymentModule(additional);bdm.addService(EjbInjectionServices.class, ejbInjectionServices);
}
}
for (Map.Entry<ModuleIdentifier, BeanDeploymentModule> entry : bdmsByIdentifier.entrySet()) {
final ModuleSpecification bdmSpec = moduleSpecByIdentifier.get(entry.getKey());
final BeanDeploymentModule bdm = entry.getValue();
if (bdm == rootBeanDeploymentModule) {
continue; // the root module only has access to itself
}
for (ModuleDependency dependency : bdmSpec.getSystemDependencies()) {
BeanDeploymentModule other = bdmsByIdentifier.get(dependency.getIdentifier());
if (other != null && other != bdm) {
bdm.addBeanDeploymentModule(other);
}
}
}
final EjbInjectionServices ejbInjectionServices = new WeldEjbInjectionServices(deploymentUnit.getServiceRegistry(), eeModuleDescription, eeApplicationDescription, deploymentRoot.getRoot());
rootBeanDeploymentModule.addService(EjbInjectionServices.class, ejbInjectionServices);
for(final BeanDeploymentModule additional : deploymentUnit.getAttachmentList(WeldAttachments.ADDITIONAL_BEAN_DEPLOYMENT_MODULES)) {
beanDeploymentArchives.addAll(additional.getBeanDeploymentArchives());