| java.net.URLClassLoader org.codehaus.groovy.tools.RootLoader
RootLoader | public class RootLoader extends URLClassLoader (Code) | | 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 frist check parent and then look in
the ressources you gave this classloader.
It's possible to add urls to the classpath at runtime through
See Also: RootLoader.addURL(URL) See Also: Why using RootLoader? See Also: If you have to load classes with multiple classloaders and a See Also: classloader does know a class which depends on a class only See Also: a child of this loader does know, then you won't be able to See Also: load the class. To load the class the child is not allowed See Also: to redirect it's search for the class to the parent first. See Also: That way the child can load the class. If the child does not See Also: have all classes to do this, this fails of course. See Also: For example: See Also: See Also: parentLoader (has classpath: a.jar;c.jar) See Also: | See Also: | See Also: childLoader (has classpath: a.jar;b.jar;c.jar) See Also:
See Also: class C (from c.jar) extends B (from b.jar) See Also: childLoader.find("C") See Also: --> parentLoader does know C.class, try to load it See Also: --> to load C.class it has to load B.class See Also: --> parentLoader is unable to find B.class in a.jar or c.jar See Also: --> NoClassDefFoundException! See Also: if childLoader had tried to load the class by itself, there See Also: would be no problem. Changing childLoader to be a RootLoader See Also: instance will solve that problem. author: Jochen Theodorou |
RootLoader | public RootLoader(URL[] urls, ClassLoader parent)(Code) | | constructs a new RootLoader with a parent loader and an
array of URLs as classpath
|
RootLoader | public RootLoader(LoaderConfiguration lc)(Code) | | constructs a new RootLoader with a @see LoaderConfiguration
object which holds the classpath
|
addURL | public void addURL(URL url)(Code) | | adds an url to the classpath of this classloader
|
getResource | public URL getResource(String name)(Code) | | returns the URL of a resource, or null if it is not found
|
|
|