gate.util
Class GateClassLoader

java.lang.Object
  extended byjava.lang.ClassLoader
      extended byjava.security.SecureClassLoader
          extended byjava.net.URLClassLoader
              extended bygate.util.GateClassLoader

public class GateClassLoader
extends URLClassLoader

GATE's class loader, which allows loading of classes over the net. A list of URLs is searched, which should point at .jar files or to directories containing class file hierarchies. The class loader is unusual in supporting reloading of classes, which is useful for CREOLE developers who want to recompile modules without relaunching GATE. The loader is also used for creating JAPE RHS action classes.


Constructor Summary
GateClassLoader()
          Default construction - use an empty URL list.
GateClassLoader(ClassLoader parent)
          Chaining constructor.
GateClassLoader(URL[] urls)
          Default construction with URLs list.
GateClassLoader(URL[] urls, ClassLoader parent)
          Chaining constructor with URLs list.
 
Method Summary
 void addURL(URL url)
          Appends the specified URL to the list of URLs to search for classes and resources.
 Class defineGateClass(String name, byte[] bytes, int offset, int len)
          Forward a call to super.defineClass, which is protected and final in super.
 Class loadClass(String name, boolean resolve)
          Delegate loading to the super class (loadClass has protected access there).
 Class reloadClass(String name)
          Reload a class.
 void resolveGateClass(Class c)
          Forward a call to super.resolveClass, which is protected and final in super.
 
Methods inherited from class java.net.URLClassLoader
findResource, findResources, getURLs, newInstance, newInstance
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GateClassLoader

public GateClassLoader()
Default construction - use an empty URL list.


GateClassLoader

public GateClassLoader(ClassLoader parent)
Chaining constructor.


GateClassLoader

public GateClassLoader(URL[] urls)
Default construction with URLs list.


GateClassLoader

public GateClassLoader(URL[] urls,
                       ClassLoader parent)
Chaining constructor with URLs list.

Method Detail

addURL

public void addURL(URL url)
Appends the specified URL to the list of URLs to search for classes and resources.


loadClass

public Class loadClass(String name,
                       boolean resolve)
                throws ClassNotFoundException
Delegate loading to the super class (loadClass has protected access there).

Throws:
ClassNotFoundException

defineGateClass

public Class defineGateClass(String name,
                             byte[] bytes,
                             int offset,
                             int len)
Forward a call to super.defineClass, which is protected and final in super. This is used by JAPE and the Jdk compiler class.


resolveGateClass

public void resolveGateClass(Class c)
Forward a call to super.resolveClass, which is protected and final in super. This is used by JAPE and the Jdk compiler class


reloadClass

public Class reloadClass(String name)
                  throws ClassNotFoundException
Reload a class. This works on the assumption that all classes that we are asked to reload will have been loaded by a GateClassLoader and not the system class loader. If this is not the case, this method will simply return the previously loaded class (because of the delegation chaining model of class loaders in JDK1.2 and above).

The method works by avoiding the normal chaining behaviour of class loaders by creating a star-shaped group of parallel loaders. Each of these chains of the system class loader, but as long as the class that we wish to reload wan't loaded by the system loader, it will not be present in a new loader of this type.

An implication is that reloaded classes must always be instantiated via the class returned from this method.

Throws:
ClassNotFoundException