use of org.apache.openejb.core.EmptyResourcesClassLoader in project tomee by apache.
the class ConfigurableClasspathArchive method archive.
public static Archive archive(final Module module, final URL location, final boolean forceDescriptor) {
final ClassLoader loader = module.getClassLoader();
final String name = "META-INF/" + name();
try {
final URL scanXml = new URLClassLoader(new URL[] { location }, new EmptyResourcesClassLoader()).getResource(name);
if (scanXml == null && !forceDescriptor) {
return ClasspathArchive.archive(loader, location);
} else if (scanXml == null) {
return new ClassesArchive();
}
// read descriptors
final ScanUtil.ScanHandler scan = ScanUtil.read(scanXml);
final Archive packageArchive = packageArchive(scan.getPackages(), loader, location);
final Archive classesArchive = classesArchive(scan.getPackages(), scan.getClasses(), loader);
if (packageArchive != null && classesArchive != null) {
return new CompositeArchive(classesArchive, packageArchive);
} else if (packageArchive != null) {
return packageArchive;
}
return classesArchive;
} catch (final IOException e) {
if (forceDescriptor) {
return new ClassesArchive();
}
return ClasspathArchive.archive(loader, location);
}
}
use of org.apache.openejb.core.EmptyResourcesClassLoader in project tomee by apache.
the class DeploymentLoader method addBeansXmls.
public static void addBeansXmls(final WebModule webModule) {
final List<URL> urls = webModule.getScannableUrls();
// parent returns nothing when calling getresources because we don't want here to be fooled by maven classloader
final URLClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), new EmptyResourcesClassLoader());
final List<URL> xmls = new LinkedList<>();
try {
final URL e = (URL) webModule.getAltDDs().get("beans.xml");
if (e != null) {
// first!
xmls.add(e);
}
xmls.addAll(Collections.list(loader.getResources("META-INF/beans.xml")));
} catch (final IOException e) {
return;
}
final CompositeBeans complete = new CompositeBeans();
for (final URL url : xmls) {
if (url == null) {
continue;
}
mergeBeansXml(complete, url);
}
if (!complete.getDiscoveryByUrl().isEmpty()) {
complete.removeDuplicates();
}
webModule.getAltDDs().put("beans.xml", complete);
}
Aggregations