GATE
Version 3.1-2270

gate.util
Class GateClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by gate.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 findExistingClass(String name)
          Given a fully qualified class name, this method returns the instance of Class if it is already loaded using the ClassLoader or it returns null.
 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
definePackage, findClass, 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, 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.

Overrides:
addURL in class URLClassLoader

loadClass

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

Overrides:
loadClass in class ClassLoader
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


findExistingClass

public Class findExistingClass(String name)
Given a fully qualified class name, this method returns the instance of Class if it is already loaded using the ClassLoader or it returns null.

Parameters:
name -
Returns:

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

GATE
Version 3.1-2270