shared.metaclass
Class RegistryClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by shared.metaclass.RegistryClassLoader
All Implemented Interfaces:
ResourceRegistry

public class RegistryClassLoader
extends SecureClassLoader
implements ResourceRegistry

A subclass of SecureClassLoader that derives classes and resource URLs from a registry delegation chain.


Nested Class Summary
protected  class RegistryClassLoader.PrefixNode
          A node class for policy hierarchy lookups.
 
Constructor Summary
RegistryClassLoader()
          Default constructor.
RegistryClassLoader(ClassLoader parent)
          Alternate constructor.
 
Method Summary
 RegistryClassLoader addClass(String className)
          Adds a class which requires, for linking purposes, resources exclusive to this class loader.
 RegistryClassLoader addPackage(String packageName)
          Adds a package whose classes require, for linking purposes, resources exclusive to this class loader.
 RegistryClassLoader addRegistry(ResourceRegistry registry)
          Adds a registry to the delegation chain.
protected  Class<?> findClass(String className)
          Attempts to derive a class from the registry delegation chain.
protected  URL findResource(String pathname)
           
protected  Enumeration<URL> findResources(String pathname)
           
 InputStream getResourceAsStream(String pathname)
          Gets an InputStream to the resource at the given pathname.
protected  Class<?> loadClass(String className, boolean resolve)
          Attempts to derive a class first from this class loader's parent, and then from its findClass(String) method.
 void loadLibrary(String libraryName)
          Attempts to load a native library first from the class path, and then from the system's dynamic linker.
 String toString()
          Creates a human-readable representation of this class loader.
 
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass, getPermissions
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, 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
 
Methods inherited from interface shared.metaclass.ResourceRegistry
getResource, getResources
 

Constructor Detail

RegistryClassLoader

public RegistryClassLoader()
Default constructor.


RegistryClassLoader

public RegistryClassLoader(ClassLoader parent)
Alternate constructor.

Method Detail

loadClass

protected Class<?> loadClass(String className,
                             boolean resolve)
                      throws ClassNotFoundException
Attempts to derive a class first from this class loader's parent, and then from its findClass(String) method.

Overrides:
loadClass in class ClassLoader
Throws:
ClassNotFoundException - when the class could not be found.

findClass

protected Class<?> findClass(String className)
                      throws ClassNotFoundException
Attempts to derive a class from the registry delegation chain.

Overrides:
findClass in class ClassLoader
Throws:
ClassNotFoundException - when the class could not be found.

findResource

protected URL findResource(String pathname)
Overrides:
findResource in class ClassLoader

findResources

protected Enumeration<URL> findResources(String pathname)
                                  throws IOException
Overrides:
findResources in class ClassLoader
Throws:
IOException

getResourceAsStream

public InputStream getResourceAsStream(String pathname)
Description copied from interface: ResourceRegistry
Gets an InputStream to the resource at the given pathname.

Specified by:
getResourceAsStream in interface ResourceRegistry
Overrides:
getResourceAsStream in class ClassLoader
Parameters:
pathname - the resource pathname.
Returns:
an InputStream to the resource or null if not found.

loadLibrary

public void loadLibrary(String libraryName)
Attempts to load a native library first from the class path, and then from the system's dynamic linker.


addRegistry

public RegistryClassLoader addRegistry(ResourceRegistry registry)
Adds a registry to the delegation chain.


addClass

public RegistryClassLoader addClass(String className)
Adds a class which requires, for linking purposes, resources exclusive to this class loader.


addPackage

public RegistryClassLoader addPackage(String packageName)
Adds a package whose classes require, for linking purposes, resources exclusive to this class loader.


toString

public String toString()
Creates a human-readable representation of this class loader.

Overrides:
toString in class Object