Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

abbot.script
Class AppClassLoader  view AppClassLoader download AppClassLoader.java

java.lang.Object
  extended byjava.lang.ClassLoader
      extended byjava.security.SecureClassLoader
          extended byjava.net.URLClassLoader
              extended byabbot.util.PathClassLoader
                  extended byabbot.util.PreloadingClassLoader
                      extended byabbot.script.AppClassLoader

public class AppClassLoader
extends abbot.util.PreloadingClassLoader

A custom class loader which installs itself as if it were the application class loader, optionally preloading all classes. 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.

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 will never be delegated, since it does not work properly unless it is reloaded.


Nested Class Summary
private  class AppClassLoader.AppEventQueue
           
private  class AppClassLoader.BootstrapClassLoader
          Provide access to bootstrap classes that must be preloaded.
 
Nested classes inherited from class abbot.util.PathClassLoader
 
Nested classes inherited from class java.net.URLClassLoader
 
Nested classes inherited from class java.lang.ClassLoader
 
Field Summary
private  AppClassLoader.BootstrapClassLoader bootstrapLoader
          For use in checking if a class is in the bootstrap class path.
private static java.lang.String[] bootstrapPrefixes
           
private  java.lang.String classPath
           
private  abbot.util.PreloadingClassLoader defaultPathLoader
          For use in checking if a class is in the framework class path.
private  AppClassLoader.AppEventQueue eventQueue
          A new event queue installed for the lifetime of this class loader.
private  java.lang.Thread installedThread
           
private  java.lang.String[] mustPreloadPrefixes
          List of bootstrap classes we most definitely want to be loaded by this class loader, rather than any parent, or the bootstrap loader.
private  java.lang.ClassLoader oldClassLoader
          Old class loader context for the thread where this loader was installed.
private  java.lang.String oldClassPath
           
protected static java.lang.String PS
           
 
Fields inherited from class abbot.util.PreloadingClassLoader
 
Fields inherited from class abbot.util.PathClassLoader
 
Fields inherited from class java.net.URLClassLoader
 
Fields inherited from class java.security.SecureClassLoader
 
Fields inherited from class java.lang.ClassLoader
 
Constructor Summary
AppClassLoader(java.lang.String classPath, boolean delegate)
          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
 java.lang.Class findClass(java.lang.String name)
          Finds and loads the class with the specified name from the search path.
protected  java.lang.String getBootstrapPath()
          Returns the path to the primary JRE classes, not including any extensions.
 void install()
          Ensure that everything else subsequently loaded on the same thread or any subsequently spawned threads uses the given class loader.
(package private)  boolean isBootstrapClass(java.lang.String name)
           
private  boolean isExtension(java.lang.String name)
           
private  boolean mustPreload(java.lang.String name)
          Does the given class absolutely need to be preloaded?
protected  boolean shouldDelegate(java.lang.String name)
           
 void uninstall()
          Reverse the effects of install.
 
Methods inherited from class abbot.util.PreloadingClassLoader
loadClass
 
Methods inherited from class abbot.util.PathClassLoader
getClassPath
 
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findResource, findResources, getPermissions, getURLs, newInstance, newInstance, toString
 
Methods inherited from class java.security.SecureClassLoader
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
 

Field Detail

PS

protected static final java.lang.String PS

eventQueue

private AppClassLoader.AppEventQueue eventQueue
A new event queue installed for the lifetime of this class loader.


bootstrapLoader

private AppClassLoader.BootstrapClassLoader bootstrapLoader
For use in checking if a class is in the bootstrap class path.


defaultPathLoader

private abbot.util.PreloadingClassLoader defaultPathLoader
For use in checking if a class is in the framework class path.


classPath

private java.lang.String classPath

oldClassLoader

private java.lang.ClassLoader oldClassLoader
Old class loader context for the thread where this loader was installed.


installedThread

private java.lang.Thread installedThread

oldClassPath

private java.lang.String oldClassPath

mustPreloadPrefixes

private java.lang.String[] mustPreloadPrefixes
List of bootstrap classes we most definitely want to be loaded by this class loader, rather than any parent, or the bootstrap loader.


bootstrapPrefixes

private static final java.lang.String[] bootstrapPrefixes
Constructor Detail

AppClassLoader

public AppClassLoader(java.lang.String classPath,
                      boolean delegate)
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(java.lang.String name)

isExtension

private boolean isExtension(java.lang.String name)

getBootstrapPath

protected java.lang.String getBootstrapPath()
Returns the path to the primary JRE classes, not including any extensions. This is primarily needed for loading sun.applet.AppletViewer, since most other classes in the bootstrap path should only be loaded by the bootstrap loader.


findClass

public java.lang.Class findClass(java.lang.String name)
                          throws java.lang.ClassNotFoundException
Finds and loads the class with the specified name from the search path. If the class is a bootstrap class, use our own bootstrap loader.


isBootstrapClass

boolean isBootstrapClass(java.lang.String name)

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.


mustPreload

private boolean mustPreload(java.lang.String name)
Does the given class absolutely need to be preloaded?