Search in sources :

Example 16 with Archive

use of org.jboss.shrinkwrap.api.Archive in project tomee by apache.

the class SWClassLoader method findNodes.

public LinkedList<Archive<?>> findNodes(final String name) {
    final LinkedList<Archive<?>> items = new LinkedList<>();
    for (final Archive<?> a : archives) {
        final boolean isWar = WebArchive.class.isInstance(a);
        final Node node = a.get(ArchivePaths.create((isWar ? "/WEB-INF/classes/" : "") + name));
        if (node != null) {
            items.add(a);
        }
    }
    return items;
}
Also used : WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) Archive(org.jboss.shrinkwrap.api.Archive) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) Node(org.jboss.shrinkwrap.api.Node) LinkedList(java.util.LinkedList)

Example 17 with Archive

use of org.jboss.shrinkwrap.api.Archive in project tomee by apache.

the class ArchiveResourceIteratorFactory method findResources.

private Collection<Resource> findResources(final String path, final String suffix) {
    final ClassLoader loader = Thread.currentThread().getContextClassLoader();
    final Collection<Resource> resources = new ArrayList<Resource>();
    if (SWClassLoader.class.isInstance(loader)) {
        final Collection<Archive<?>> archives = SWClassLoader.class.cast(loader).getArchives();
        final ClassLoader parent = loader.getParent();
        for (final Archive<?> archive : archives) {
            final Map<ArchivePath, Node> content = archive.getContent(new Filter<ArchivePath>() {

                @Override
                public boolean include(final ArchivePath object) {
                    final String currentPath = classloaderPath(object);
                    return !(parent != null && parent.getResource(currentPath) != null) && currentPath.startsWith('/' + path) && currentPath.endsWith(suffix);
                }
            });
            for (final Map.Entry<ArchivePath, Node> entry : content.entrySet()) {
                resources.add(new SWResource(entry.getKey(), entry.getValue()));
            }
        }
    }
    return resources;
}
Also used : Archive(org.jboss.shrinkwrap.api.Archive) Node(org.jboss.shrinkwrap.api.Node) Resource(cucumber.runtime.io.Resource) ArrayList(java.util.ArrayList) SWClassLoader(org.apache.openejb.arquillian.openejb.SWClassLoader) ArchivePath(org.jboss.shrinkwrap.api.ArchivePath) SWClassLoader(org.apache.openejb.arquillian.openejb.SWClassLoader) Map(java.util.Map)

Example 18 with Archive

use of org.jboss.shrinkwrap.api.Archive in project tomee by apache.

the class ArquillianUtil method addClass.

private static void addClass(final Collection<Archive<?>> list, final ClassLoader loader, final String classname) {
    final String name = classname.trim();
    try {
        final Class<?> clazz = loader.loadClass(name);
        for (final Method m : clazz.getMethods()) {
            final int modifiers = m.getModifiers();
            if (Object.class.equals(m.getDeclaringClass()) || !Archive.class.isAssignableFrom(m.getReturnType()) || !Modifier.isStatic(modifiers) || !Modifier.isPublic(modifiers)) {
                continue;
            }
            for (final Annotation a : m.getAnnotations()) {
                if ("org.jboss.arquillian.container.test.api.Deployment".equals(a.annotationType().getName())) {
                    final Archive<?> archive = (Archive<?>) m.invoke(null);
                    list.add(archive);
                    break;
                }
            }
        }
    } catch (final Exception e) {
        throw new OpenEJBRuntimeException(e);
    }
}
Also used : OpenEJBRuntimeException(org.apache.openejb.OpenEJBRuntimeException) Archive(org.jboss.shrinkwrap.api.Archive) Method(java.lang.reflect.Method) Annotation(java.lang.annotation.Annotation) OpenEJBRuntimeException(org.apache.openejb.OpenEJBRuntimeException) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException)

Example 19 with Archive

use of org.jboss.shrinkwrap.api.Archive in project core by weld.

the class DuplicateInterceptorTest method deploy.

@Deployment
public static Archive<?> deploy() {
    Archive jar = ShrinkWrap.create(JavaArchive.class).addClasses(MySuperClass.class);
    Archive beanArchive = ShrinkWrap.create(BeanArchive.class).intercept(MyInterceptor.class).addClasses(MyObject.class, MyManagedBean.class, MyInterceptor.class, MyInterceptorBinding.class, MyStereotype.class);
    return ShrinkWrap.create(WebArchive.class, Utils.getDeploymentNameAsHash(DuplicateInterceptorTest.class, Utils.ARCHIVE_TYPE.WAR)).addAsLibraries(jar, beanArchive);
}
Also used : BeanArchive(org.jboss.shrinkwrap.api.BeanArchive) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) Archive(org.jboss.shrinkwrap.api.Archive) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 20 with Archive

use of org.jboss.shrinkwrap.api.Archive in project wildfly-swarm by wildfly-swarm.

the class MockArtifactResolver method add.

public void add(ArtifactSpec spec, Consumer<Entry> config) {
    Archive archive = ShrinkWrap.create(JavaArchive.class);
    archive.add(EmptyAsset.INSTANCE, "nothing");
    Entry entry = new Entry(spec);
    config.accept(entry);
    this.entries.put(spec, entry);
    this.artifacts.put(spec, archive);
}
Also used : Archive(org.jboss.shrinkwrap.api.Archive) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive)

Aggregations

Archive (org.jboss.shrinkwrap.api.Archive)37 Node (org.jboss.shrinkwrap.api.Node)17 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)12 Test (org.junit.Test)12 File (java.io.File)11 URL (java.net.URL)10 ArrayList (java.util.ArrayList)9 ArchivePath (org.jboss.shrinkwrap.api.ArchivePath)8 JolokiaFraction (org.wildfly.swarm.jolokia.JolokiaFraction)8 BufferedReader (java.io.BufferedReader)7 IOException (java.io.IOException)7 InputStreamReader (java.io.InputStreamReader)7 Map (java.util.Map)7 HashMap (java.util.HashMap)6 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)6 List (java.util.List)5 ZipImporter (org.jboss.shrinkwrap.api.importer.ZipImporter)5 DeploymentContext (org.wildfly.swarm.container.runtime.cdi.DeploymentContext)5 JARArchive (org.wildfly.swarm.spi.api.JARArchive)5 Path (java.nio.file.Path)4