Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
private static class CompositeClassLoader extends ClassLoader {
private Vector<ClassLoader> classLoaders = new Vector<ClassLoader>();
@Override
public URL getResource(String name) {
for (ClassLoader cl : classLoaders) {
URL resource = cl.getResource(name);
if (resource != null)
return resource;
}
return null;
}
@Override
public Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
for (ClassLoader cl : classLoaders) {
try {
return cl.loadClass(name);
} catch (ClassNotFoundException ex) {
}
}
throw new ClassNotFoundException(name);
}
public void addClassLoader(ClassLoader cl) {
classLoaders.add(cl);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment