use of org.eclipse.jetty.webapp.JarScanner in project jetty.project by eclipse.
the class AnnotationParser method parse.
/**
* Parse classes in the supplied classloader.
* Only class files in jar files will be scanned.
*
* @param handlers the handlers to look for classes in
* @param loader the classloader for the classes
* @param visitParents if true, visit parent classloaders too
* @param nullInclusive if true, an empty pattern means all names match, if false, none match
* @throws Exception if unable to parse
*/
public void parse(final Set<? extends Handler> handlers, ClassLoader loader, boolean visitParents, boolean nullInclusive) throws Exception {
if (loader == null)
return;
if (!(loader instanceof URLClassLoader))
//can't extract classes?
return;
final MultiException me = new MultiException();
JarScanner scanner = new JarScanner() {
@Override
public void processEntry(URI jarUri, JarEntry entry) {
try {
parseJarEntry(handlers, Resource.newResource(jarUri), entry);
} catch (Exception e) {
me.add(new RuntimeException("Error parsing entry " + entry.getName() + " from jar " + jarUri, e));
}
}
};
scanner.scan(null, loader, nullInclusive, visitParents);
me.ifExceptionThrow();
}
Aggregations