use of org.jboss.as.weld.spi.ImplicitBeanArchiveDetector in project wildfly by wildfly.
the class WeldImplicitDeploymentProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (WeldDeploymentMarker.isWeldDeployment(deploymentUnit)) {
return;
}
if (Utils.getRootDeploymentUnit(deploymentUnit).getAttachment(WeldConfiguration.ATTACHMENT_KEY).isRequireBeanDescriptor()) {
// if running in the require-bean-descriptor mode then bean archives are found by BeansXmlProcessor
return;
}
/*
* look for classes with bean defining annotations
*/
final Set<AnnotationType> beanDefiningAnnotations = new HashSet<>(getRootDeploymentUnit(deploymentUnit).getAttachment(WeldAttachments.BEAN_DEFINING_ANNOTATIONS));
final Map<ResourceRoot, Index> indexes = AnnotationIndexUtils.getAnnotationIndexes(deploymentUnit);
final ExplicitBeanArchiveMetadataContainer explicitBeanArchiveMetadata = deploymentUnit.getAttachment(ExplicitBeanArchiveMetadataContainer.ATTACHMENT_KEY);
final ResourceRoot classesRoot = deploymentUnit.getAttachment(WeldAttachments.CLASSES_RESOURCE_ROOT);
final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
for (Entry<ResourceRoot, Index> entry : indexes.entrySet()) {
ResourceRoot resourceRoot = entry.getKey();
if (resourceRoot == classesRoot) {
// BDA for WEB-INF/classes is keyed under deploymentRoot in explicitBeanArchiveMetadata
resourceRoot = deploymentRoot;
}
/*
* Make sure bean defining annotations used in archives with bean-discovery-mode="none" are not considered here
* WFLY-4388
*/
if (explicitBeanArchiveMetadata != null && explicitBeanArchiveMetadata.getBeanArchiveMetadata().containsKey(resourceRoot)) {
continue;
}
for (final AnnotationType annotation : beanDefiningAnnotations) {
if (!entry.getValue().getAnnotations(annotation.getName()).isEmpty()) {
WeldDeploymentMarker.mark(deploymentUnit);
return;
}
}
}
/*
* look for session beans and managed beans
*/
final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
final Iterable<ImplicitBeanArchiveDetector> detectors = ServiceLoader.load(ImplicitBeanArchiveDetector.class, WildFlySecurityManager.getClassLoaderPrivileged(WeldImplicitDeploymentProcessor.class));
for (ComponentDescription component : eeModuleDescription.getComponentDescriptions()) {
for (ImplicitBeanArchiveDetector detector : detectors) {
if (detector.isImplicitBeanArchiveRequired(component)) {
WeldDeploymentMarker.mark(deploymentUnit);
return;
}
}
}
}
Aggregations