Search in sources :

Example 1 with BeanArchiveBuilder

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;
}
Also used : BeanArchiveBuilder(org.jboss.weld.environment.deployment.discovery.BeanArchiveBuilder) Index(org.jboss.jandex.Index) File(java.io.File) ZipFile(java.util.zip.ZipFile)

Example 2 with BeanArchiveBuilder

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;
}
Also used : BeanArchiveBuilder(org.jboss.weld.environment.deployment.discovery.BeanArchiveBuilder)

Example 3 with BeanArchiveBuilder

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;
}
Also used : ZipInputStream(java.util.zip.ZipInputStream) InputStream(java.io.InputStream) BeanArchiveBuilder(org.jboss.weld.environment.deployment.discovery.BeanArchiveBuilder) IOException(java.io.IOException) URL(java.net.URL)

Example 4 with BeanArchiveBuilder

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"));
}
Also used : BeanArchiveBuilder(org.jboss.weld.environment.deployment.discovery.BeanArchiveBuilder) Test(org.junit.Test)

Example 5 with BeanArchiveBuilder

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);
}
Also used : IndexView(org.jboss.jandex.IndexView) ArrayList(java.util.ArrayList) BeanArchiveBuilder(org.jboss.weld.environment.deployment.discovery.BeanArchiveBuilder)

Aggregations

BeanArchiveBuilder (org.jboss.weld.environment.deployment.discovery.BeanArchiveBuilder)6 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 ZipFile (java.util.zip.ZipFile)1 ZipInputStream (java.util.zip.ZipInputStream)1 Index (org.jboss.jandex.Index)1 IndexView (org.jboss.jandex.IndexView)1 Test (org.junit.Test)1