abbot.util
Class NonDelegatingClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by abbot.util.PathClassLoader
                  extended by 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.


Constructor Summary
NonDelegatingClassLoader(String path, ClassLoader parent)
           
 
Method Summary
 Class findClass(String name)
          Find the given class in the search path.
protected  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
convertPathToFilenames, convertPathToFilenames, convertPathToFiles, getClassPath, getURLs, toString
 
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findResource, findResources, getPermissions, getURLs, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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
Throws:
ClassNotFoundException

loadClass

protected 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
Throws:
ClassNotFoundException


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

SourceForge