ClassLoader that is composed of other classloaders. Each loader will be used to try to load the particular class, until one of them succeeds.
Note: The loaders will always be called in the REVERSE order they were added in.
The Composite class loader also has registered the classloader that loaded xstream.jar and (if available) the thread's context classloader.
Example
CompositeClassLoader loader = new CompositeClassLoader(); loader.add(MyClass.class.getClassLoader()); loader.add(new AnotherClassLoader()); loader.loadClass("com.blah.ChickenPlucker");
The above code will attempt to load a class from the following classloaders (in order):
- AnotherClassLoader (and all its parents)
- The classloader for MyClas (and all its parents)
- The thread's context classloader (and all its parents)
- The classloader for XStream (and all its parents)
The added classloaders are kept with weak references to allow an application container to reload classes.
@author Joe Walnes
@author Jörg Schaible
@since 1.0.3