use of org.jboss.weld.environment.deployment.discovery.BeanArchiveBuilder in project core by weld.
the class JandexIndexBeanArchiveHandler method handle.
@Override
public BeanArchiveBuilder handle(String path) {
File beanArchiveFile = new File(path);
if (!beanArchiveFile.canRead() || beanArchiveFile.isDirectory()) {
// Currently only JAR files are supported
return null;
}
Index index = getIndex(beanArchiveFile);
if (index == null) {
return null;
}
BeanArchiveBuilder builder = new BeanArchiveBuilder().setAttribute(Jandex.INDEX_ATTRIBUTE_NAME, index);
handleArchiveByIndex(index, builder);
return builder;
}
use of org.jboss.weld.environment.deployment.discovery.BeanArchiveBuilder in project core by weld.
the class JandexServletContextBeanArchiveHandler method handle.
@Override
public BeanArchiveBuilder handle(String path) {
BeanArchiveBuilder builder = super.handle(path);
if (builder == null) {
return null;
}
builder.setAttribute(Jandex.INDEX_ATTRIBUTE_NAME, buildIndex());
return builder;
}
use of org.jboss.weld.environment.deployment.discovery.BeanArchiveBuilder in project core by weld.
the class ServletContextBeanArchiveHandler method handle.
@Override
public BeanArchiveBuilder handle(String path) {
if (path.equals(WebAppBeanArchiveScanner.WEB_INF_CLASSES)) {
BeanArchiveBuilder builder = new BeanArchiveBuilder();
handleResourcePath(path, path, builder);
return builder;
} else if (path.startsWith(PROTOCOL_WAR_PART)) {
try {
URL url = new URL(path);
InputStream in = url.openStream();
if (in != null) {
BeanArchiveBuilder builder = new BeanArchiveBuilder();
handleLibrary(url, in, builder);
return builder;
}
} catch (IOException e) {
WeldServletLogger.LOG.cannotHandleLibrary(path, e);
}
}
return null;
}
use of org.jboss.weld.environment.deployment.discovery.BeanArchiveBuilder in project core by weld.
the class ServletContextBeanArchiveHandlerTest method testHandleResourcePath.
@Test
public void testHandleResourcePath() {
ServletContextBeanArchiveHandler handler = new ServletContextBeanArchiveHandler(new ServletContextMock());
BeanArchiveBuilder builder = handler.handle(WebAppBeanArchiveScanner.WEB_INF_CLASSES);
Collection<String> classes = builder.getClasses();
assertEquals(4, classes.size());
assertTrue(classes.contains("org.Alpha"));
assertTrue(classes.contains("org.foo.Bravo"));
assertTrue(classes.contains("org.foo.Charlie"));
assertTrue(classes.contains("org.bar.Delta"));
}
use of org.jboss.weld.environment.deployment.discovery.BeanArchiveBuilder in project core by weld.
the class JandexDiscoveryStrategy method beforeDiscovery.
@Override
protected void beforeDiscovery(Collection<BeanArchiveBuilder> builders) {
List<IndexView> indexes = new ArrayList<IndexView>();
for (BeanArchiveBuilder builder : builders) {
IndexView index = (IndexView) builder.getAttribute(Jandex.INDEX_ATTRIBUTE_NAME);
if (index != null) {
indexes.add(index);
}
}
cindex = CompositeIndex.create(indexes);
beanDefiningAnnotations = buildBeanDefiningAnnotationSet(initialBeanDefiningAnnotations, cindex);
classFileServices = new JandexClassFileServices(this);
}
Aggregations