Created
May 21, 2009 02:27
-
-
Save sporkmonger/115228 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sporkmonger.util; | |
import java.net.URL; | |
import java.util.ArrayList; | |
public class HydraLoader extends ClassLoader { | |
private ArrayList<ClassLoader> childLoaders = new ArrayList<ClassLoader>(); | |
public HydraLoader() { | |
super(); | |
childLoaders.add(this.getParent()); | |
} | |
public HydraLoader(ClassLoader parent) { | |
super(parent); | |
childLoaders.add(this.getParent()); | |
} | |
public void addLoader(ClassLoader loader) { | |
childLoaders.add(loader); | |
} | |
@Override | |
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { | |
for (ClassLoader loader : childLoaders) { | |
try { | |
return loader.loadClass(name); | |
} catch (ClassNotFoundException e) { | |
} | |
} | |
throw new ClassNotFoundException("FAIL!"); | |
} | |
// | |
// @Override | |
// public URL getResource(String name) { | |
// for (ClassLoader loader : childLoaders) { | |
// URL result = loader.getResource(name); | |
// if (result != null) { | |
// return result; | |
// } | |
// } | |
// return null; | |
// } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment