org.jwalk
Class GeneratorLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by org.jwalk.GeneratorLoader
Direct Known Subclasses:
TestClassLoader

public class GeneratorLoader
extends java.net.URLClassLoader

GeneratorLoader is a class loader for loading custom generators. A single GeneratorLoader is constructed for each JWalk runtime. This permits each CustomGenerator class to be loaded once per runtime (and once loaded, a CustomGenerator class cannot be reloaded).

Version:
1.0
Author:
Anthony Simons

Constructor Summary
GeneratorLoader(java.lang.ClassLoader delegate)
          Creates a GeneratorLoader that delegates to another loader.
 
Method Summary
 boolean addDirectory(java.io.File directory)
          Adds a directory path to the current list of search paths.
 
Methods inherited from class java.net.URLClassLoader
addURL, 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, 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

GeneratorLoader

public GeneratorLoader(java.lang.ClassLoader delegate)
Creates a GeneratorLoader that delegates to another loader. This GeneratorLoader initially has an empty list of search paths. When loading a class file, this GeneratorLoader first seeks whether its delegate ClassLoader has already loaded the class, in which case the cached class is returned. Otherwise, this GeneratorLoader will load the class from one of the directories added to its current search directory paths.

Parameters:
delegate - the delegate ClassLoader to use first.
Method Detail

addDirectory

public boolean addDirectory(java.io.File directory)
Adds a directory path to the current list of search paths. If the directory is not already one of this GeneratorLoader's search paths, adds this path to the list and returns true. Otherwise, leaves the current list of paths unchanged and returns false. If the directory is a malformed path, returns false.

Parameters:
directory - a directory path.
Returns:
true, if the path was added.