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;
}
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;
}
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);
}
}
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);
}
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);
}
Aggregations