private BeanDeploymentArchiveImpl processResourceRoot(ResourceRoot resourceRoot) throws DeploymentUnitProcessingException {
ExplicitBeanArchiveMetadata metadata = null;
if (explicitBeanArchives != null) {
metadata = explicitBeanArchives.getBeanArchiveMetadata().get(resourceRoot);
}
BeanDeploymentArchiveImpl bda = null;
if (metadata == null && requireBeanDescriptor) {
/*
* For compatibility with Contexts and Dependency 1.0, products must contain an option to cause an archive to be ignored by the
* container when no beans.xml is present.
*/
return null;
}
if (metadata == null || metadata.getBeansXml().getBeanDiscoveryMode().equals(BeanDiscoveryMode.ANNOTATED)) {
// this is either an implicit bean archive or not a bean archive at all!
final boolean isRootBda = resourceRoot.equals(deploymentResourceRoot);
ResourceRoot indexResourceRoot = resourceRoot;
if (resourceRoot == deploymentResourceRoot && classesResourceRoot != null) {
// this is WEB-INF/classes BDA
indexResourceRoot = classesResourceRoot;
}
final Index index = indexes.get(indexResourceRoot);
if (index == null) {
return null; // index may be null for some resource roots
}
/*
* An archive which contains an extension and no beans.xml file is not a bean archive.
*/
if (metadata == null && !index.getAllKnownImplementors(EXTENSION_NAME).isEmpty()) {
return null;
}
Set<String> beans = getImplicitBeanClasses(index, resourceRoot);
if (beans.isEmpty() && components.ejbComponentDescriptions.get(resourceRoot).isEmpty()) {
return null;
}
BeansXml beansXml = null;
if (metadata != null) {
beansXml = metadata.getBeansXml();
}
bda = new BeanDeploymentArchiveImpl(beans, beansXml, module, resourceRoot.getRoot().getPathName(), BeanArchiveType.IMPLICIT, isRootBda);
WeldLogger.DEPLOYMENT_LOGGER.beanArchiveDiscovered(bda);
} else if (metadata.getBeansXml().getBeanDiscoveryMode().equals(BeanDiscoveryMode.NONE)) {
// scanning suppressed per spec in this archive
return null;
} else {
boolean isRootBda = metadata.isDeploymentRoot();
bda = createExplicitBeanDeploymentArchive(indexes.get(metadata.getResourceRoot()), metadata, isRootBda);
WeldLogger.DEPLOYMENT_LOGGER.beanArchiveDiscovered(bda);
}
Collection<EJBComponentDescription> ejbComponents = components.ejbComponentDescriptions.get(resourceRoot);
// register EJBs with the BDA
for (EJBComponentDescription ejb : ejbComponents) {
bda.addEjbDescriptor(new EjbDescriptorImpl<Object>(ejb, bda, reflectionIndex));
bda.addBeanClass(ejb.getComponentClassName());
}
return bda;
}