org.codehaus.groovy.tools
public class: RootLoader [javadoc |
source]
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
org.codehaus.groovy.tools.RootLoader
This ClassLoader should be used as root of class loaders. Any
RootLoader does have it's own classpath. When searching for a
class or resource this classpath will be used. Parent
Classloaders are ignored first. If a class or resource
can't be found in the classpath of the RootLoader, then parent is
checked.
Note: this is very against the normal behavior of
classloaders. Normal is to first check parent and then look in
the resources you gave this classloader.
It's possible to add urls to the classpath at runtime through
| Constructor: |
public RootLoader(LoaderConfiguration lc) {
this(chooseParent());
Thread.currentThread().setContextClassLoader(this);
URL[] urls = lc.getClassPathUrls();
for (int i = 0; i < urls.length; i++) {
addURL(urls[i]);
}
}
constructs a new RootLoader with a @see LoaderConfiguration
object which holds the classpath |
public RootLoader(URL[] urls,
ClassLoader parent) {
super(urls, parent);
// major hack here...!
try{
customClasses.put("org.w3c.dom.Node",super.loadClass("org.w3c.dom.Node",false));
} catch (Exception e) {}
}
constructs a new RootLoader with a parent loader and an
array of URLs as classpath |
| Methods from java.lang.ClassLoader: |
|---|
|
clearAssertionStatus, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus |
| Method from org.codehaus.groovy.tools.RootLoader Detail: |
public void addURL(URL url) {
super.addURL(url);
}
adds an url to the classpath of this classloader |
protected Class findClass(String name) throws ClassNotFoundException {
throw new ClassNotFoundException(name);
}
|
public URL getResource(String name) {
URL url = findResource(name);
if (url == null) url = super.getResource(name);
return url;
}
returns the URL of a resource, or null if it is not found |
protected Class loadClass(String name,
boolean resolve) throws ClassNotFoundException {
Class c = this.findLoadedClass(name);
if (c != null) return c;
c = (Class) customClasses.get(name);
if (c != null) return c;
try {
c = oldFindClass(name);
} catch (ClassNotFoundException cnfe) {
// IGNORE
}
if (c == null) c = super.loadClass(name, resolve);
if (resolve) resolveClass(c);
return c;
}
loads a class using the name of the class |