abbot.util
Class NonDelegatingClassLoader

java.lang.Object
  |
  +--java.lang.ClassLoader
        |
        +--java.security.SecureClassLoader
              |
              +--java.net.URLClassLoader
                    |
                    +--abbot.util.PathClassLoader
                          |
                          +--abbot.util.NonDelegatingClassLoader
Direct Known Subclasses:
AppClassLoader

public class NonDelegatingClassLoader
extends PathClassLoader

Provides support for loading a class before checking the parent class loader for it. If the shouldDelegate method returns false for a given class name, it will defer to its parent class loader only if the class is not found in this loader's path. This provides a means for reloading classes that would otherwise be permanently cached by the app or boot class loaders.

The name for this class is not quite correct; it will delegate to its parent if it doesn't find a given class.


Inner classes inherited from class java.lang.ClassLoader
ClassLoader.NativeLibrary
 
Fields inherited from class java.lang.ClassLoader
nocerts
 
Constructor Summary
NonDelegatingClassLoader(String path, ClassLoader parent)
           
 
Method Summary
 Class findClass(String name)
          Find the given class in the search path.
 Class loadClass(String name, boolean resolve)
          Load the given class, but attempt to load before the parent if shouldDelegate returns false for the given class.
protected  boolean shouldDelegate(String name)
          Returns whether the given class should be given to the parent class loader to try before this one does.
 
Methods inherited from class abbot.util.PathClassLoader
convertPathToFiles, convertPathToFiles, getClassPath, getURLs
 
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findResource, findResources, getPermissions, getURLs, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
, defineClass
 
Methods inherited from class java.lang.ClassLoader
addClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findNative, findSystemClass, getBootstrapClassPath, getCallerClassLoader, getGetClassLoaderPerm, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, isAncestor, loadClass, loadLibrary, resolveClass, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NonDelegatingClassLoader

public NonDelegatingClassLoader(String path,
                                ClassLoader parent)
Method Detail

shouldDelegate

protected boolean shouldDelegate(String name)
Returns whether the given class should be given to the parent class loader to try before this one does. The default implementation always returns false. Making this method return true will revert to the standard class loader behavior.

findClass

public Class findClass(String name)
                throws ClassNotFoundException
Find the given class in the search path.
Overrides:
findClass in class URLClassLoader

loadClass

public Class loadClass(String name,
                       boolean resolve)
                throws ClassNotFoundException
Load the given class, but attempt to load before the parent if shouldDelegate returns false for the given class.
Overrides:
loadClass in class PathClassLoader


Copyright © 2002-2003 Timothy Wall. All Rights Reserved.
Abbot is hosted on

SourceForge