final Map<ResourceRoot, Index> indexes = AnnotationIndexUtils.getAnnotationIndexes(deploymentUnit);
final Map<ResourceRoot, BeanDeploymentArchiveImpl> bdaMap = new HashMap<ResourceRoot, BeanDeploymentArchiveImpl>();
final Module module = phaseContext.getDeploymentUnit().getAttachment(Attachments.MODULE);
BeanDeploymentArchiveImpl rootBda = null;
if (cdiDeploymentMetadata != null) {
// this can be null for ear deployments
// however we still want to create a module level bean manager
for (BeanArchiveMetadata beanArchiveMetadata : cdiDeploymentMetadata.getBeanArchiveMetadata()) {
BeanDeploymentArchiveImpl bda = createBeanDeploymentArchive(indexes.get(beanArchiveMetadata.getResourceRoot()),
beanArchiveMetadata, module, beanArchiveIdPrefix);
beanDeploymentArchives.add(bda);
bdaMap.put(beanArchiveMetadata.getResourceRoot(), bda);
if (beanArchiveMetadata.isDeploymentRoot()) {
rootBda = bda;
deploymentUnit.putAttachment(WeldAttachments.DEPLOYMENT_ROOT_BEAN_DEPLOYMENT_ARCHIVE, bda);
}
}
}
if (rootBda == null) {
BeanDeploymentArchiveImpl bda = new BeanDeploymentArchiveImpl(Collections.<String>emptySet(),
BeansXml.EMPTY_BEANS_XML, module, beanArchiveIdPrefix);
beanDeploymentArchives.add(bda);
deploymentUnit.putAttachment(WeldAttachments.DEPLOYMENT_ROOT_BEAN_DEPLOYMENT_ARCHIVE, bda);
rootBda = bda;
}