@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final DeploymentUnit topLevelDeployment = deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent();
final WeldDeploymentMetadata cdiDeploymentMetadata = deploymentUnit
.getAttachment(WeldDeploymentMetadata.ATTACHMENT_KEY);
if (!WeldDeploymentMarker.isPartOfWeldDeployment(deploymentUnit)) {
return;
}
//create a CDI injection factory
EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
final Module topLevelModule = topLevelDeployment.getAttachment(Attachments.MODULE);
if(eeModuleDescription != null) {
eeModuleDescription.addInjectionFactory(new WeldInjectionFactory(phaseContext.getServiceTarget(),deploymentUnit,topLevelModule.getClassLoader()));
}
final String beanArchiveIdPrefix;
if (deploymentUnit.getParent() == null) {
beanArchiveIdPrefix = deploymentUnit.getName();
} else {
beanArchiveIdPrefix = deploymentUnit.getParent().getName() + "." + deploymentUnit.getName();
}
final Set<BeanDeploymentArchiveImpl> beanDeploymentArchives = new HashSet<BeanDeploymentArchiveImpl>();
log.info("Processing CDI deployment: " + phaseContext.getDeploymentUnit().getName());
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()) {