use of org.jboss.weld.environment.deployment.discovery.BeanArchiveScanner.ScanResult in project core by weld.
the class AbstractDiscoveryStrategy method performDiscovery.
@Override
public Set<WeldBeanDeploymentArchive> performDiscovery() {
if (scanner == null) {
scanner = new DefaultBeanArchiveScanner(resourceLoader, bootstrap);
}
final List<BeanArchiveBuilder> beanArchiveBuilders = new ArrayList<BeanArchiveBuilder>();
final Set<String> processedRefs = new HashSet<String>();
List<BeanArchiveHandler> beanArchiveHandlers = initBeanArchiveHandlers();
for (ScanResult scanResult : scanner.scan()) {
final String ref = scanResult.getBeanArchiveRef();
if (processedRefs.contains(ref)) {
throw CommonLogger.LOG.invalidScanningResult(ref);
}
CommonLogger.LOG.processingBeanArchiveReference(ref);
processedRefs.add(ref);
BeanArchiveBuilder builder = null;
for (BeanArchiveHandler handler : beanArchiveHandlers) {
builder = handler.handle(ref);
if (builder != null) {
CommonLogger.LOG.beanArchiveReferenceHandled(ref, handler);
builder.setId(scanResult.getBeanArchiveId());
builder.setBeansXml(scanResult.getBeansXml());
beanArchiveBuilders.add(builder);
break;
}
}
if (builder == null) {
CommonLogger.LOG.beanArchiveReferenceCannotBeHandled(ref, beanArchiveHandlers);
}
}
beforeDiscovery(beanArchiveBuilders);
Set<WeldBeanDeploymentArchive> archives = new HashSet<WeldBeanDeploymentArchive>();
for (Iterator<BeanArchiveBuilder> iterator = beanArchiveBuilders.iterator(); iterator.hasNext(); ) {
BeanArchiveBuilder builder = iterator.next();
BeansXml beansXml = builder.getBeansXml();
if (beansXml != null) {
switch(beansXml.getBeanDiscoveryMode()) {
case ALL:
addToArchives(archives, processAllDiscovery(builder));
break;
case ANNOTATED:
addToArchives(archives, processAnnotatedDiscovery(builder));
break;
case NONE:
addToArchives(archives, processNoneDiscovery(builder));
break;
default:
throw CommonLogger.LOG.undefinedBeanDiscoveryValue(beansXml.getBeanDiscoveryMode());
}
} else {
// A candidate for an implicit bean archive with no beans.xml
addToArchives(archives, processAnnotatedDiscovery(builder));
}
}
for (WeldBeanDeploymentArchive archive : archives) {
archive.getServices().add(ResourceLoader.class, resourceLoader);
}
afterDiscovery(archives);
return archives;
}
Aggregations