abbot.script
Class AppClassLoader

java.lang.Object
  |
  +--java.lang.ClassLoader
        |
        +--java.security.SecureClassLoader
              |
              +--java.net.URLClassLoader
                    |
                    +--abbot.util.PathClassLoader
                          |
                          +--abbot.util.NonDelegatingClassLoader
                                |
                                +--abbot.script.AppClassLoader

public class AppClassLoader
extends NonDelegatingClassLoader

A custom class loader which installs itself as if it were the application class loader. A classpath of null is equivalent to the system property java.class.path.

The class loader may optionally load a class before the parent class loader gets a chance to look for the class (instead of the default behavior, which always delegates to the parent class loader first). This behavior enables the class to be reloaded simply by using a new instance of this class loader with each launch of the app.

This class mimics the behavior of sun.misc.Launcher$AppClassLoader as much as possible.

Bootstrap classes are always delegated to the bootstrap loader, with the exception of the sun.applet package, which should never be delegated, since it does not work properly unless it is reloaded.

The parent of this class loader will be the normal, default AppClassLoader (specifically, the class loader which loaded this class will be used).


Inner classes inherited from class java.lang.ClassLoader
ClassLoader.NativeLibrary
 
Fields inherited from class java.lang.ClassLoader
nocerts
 
Constructor Summary
AppClassLoader(String classPath)
          Constructs a AppClassLoader with a custom classpath, indicating whether the class loader should delegate to its parent class loader prior to searching for a given resource.
 
Method Summary
 Class findClass(String name)
          Finds and loads the class with the specified name from the search path.
 void install()
          Ensure that everything else subsequently loaded on the same thread or any subsequently spawned threads uses the given class loader.
protected  boolean shouldDelegate(String name)
          Should the parent class loader try to load this class first?
 void uninstall()
          Reverse the effects of install.
 
Methods inherited from class abbot.util.NonDelegatingClassLoader
loadClass
 
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

AppClassLoader

public AppClassLoader(String classPath)
Constructs a AppClassLoader with a custom classpath, indicating whether the class loader should delegate to its parent class loader prior to searching for a given resource.

The class path argument may use either a colon or semicolon to separate its elements.

Method Detail

shouldDelegate

protected boolean shouldDelegate(String name)
Should the parent class loader try to load this class first?
Overrides:
shouldDelegate in class NonDelegatingClassLoader

findClass

public Class findClass(String name)
                throws ClassNotFoundException
Finds and loads the class with the specified name from the search path. If the class is a bootstrap class and must be preloaded, use our own bootstrap loader. If it is an extension class, use our own extensions loader.
Overrides:
findClass in class NonDelegatingClassLoader
Parameters:
name - the name of the class
Returns:
the resulting class
Throws:
ClassNotFoundException - if the class could not be found

install

public void install()
Ensure that everything else subsequently loaded on the same thread or any subsequently spawned threads uses the given class loader. Also ensure that classes loaded by the event dispatch thread and threads it spawns use the given class loader.

uninstall

public void uninstall()
Reverse the effects of install. Has no effect if the class loader has not been installed on any thread.


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

SourceForge