org.freecompany.brimstone.module
Class InvertedClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by org.freecompany.brimstone.module.InvertedClassLoader

public class InvertedClassLoader
extends java.net.URLClassLoader

Inverts the basic class loader delegation model to allow the same resource to exist in multiple locations within a single tree of class loaders.


Constructor Summary
InvertedClassLoader()
          Creates an inverted class loader with no parent and no source URLs.
InvertedClassLoader(java.lang.ClassLoader parent)
          Creates an inverted class loader with no source URLs which uses the provided parent loader.
InvertedClassLoader(java.net.URL[] urls)
          Creates an inverted class loader with no parent and with the specified source URLs.
InvertedClassLoader(java.net.URL[] urls, java.lang.ClassLoader parent)
          Creates an inverted class loader with the specified source URLs and which uses the provided parent loader.
 
Method Summary
 void addURL(java.net.URL url)
          In this class loader the standard URLClassLoader.addURL(java.net.URL) method is promoted to allow modifying the list of URLs at runtime.
 java.net.URL getResource(java.lang.String name)
          Reverses the ordering of the normal ClassLoader.getResource(java.lang.String) method to first search this loader and to delegate only if the resource is not found.
 java.util.Enumeration<java.net.URL> getResources(java.lang.String name)
          Reverses the ordering of the normal ClassLoader.getResources(java.lang.String) method to first search this loader and to delegate only if no resource can be found.
 java.lang.Class<?> loadClass(java.lang.String name)
          Reverses the ordering of the normal ClassLoader.loadClass(java.lang.String) method to first search this loader and to delegate only if the class is not found.
 
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, getResourceAsStream, 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

InvertedClassLoader

public InvertedClassLoader()
Creates an inverted class loader with no parent and no source URLs.


InvertedClassLoader

public InvertedClassLoader(java.lang.ClassLoader parent)
Creates an inverted class loader with no source URLs which uses the provided parent loader.


InvertedClassLoader

public InvertedClassLoader(java.net.URL[] urls)
Creates an inverted class loader with no parent and with the specified source URLs.


InvertedClassLoader

public InvertedClassLoader(java.net.URL[] urls,
                           java.lang.ClassLoader parent)
Creates an inverted class loader with the specified source URLs and which uses the provided parent loader.

Method Detail

addURL

public void addURL(java.net.URL url)
In this class loader the standard URLClassLoader.addURL(java.net.URL) method is promoted to allow modifying the list of URLs at runtime.

Overrides:
addURL in class java.net.URLClassLoader

loadClass

public java.lang.Class<?> loadClass(java.lang.String name)
                             throws java.lang.ClassNotFoundException
Reverses the ordering of the normal ClassLoader.loadClass(java.lang.String) method to first search this loader and to delegate only if the class is not found. This loader is aware of the DelegatingClassLoader and will interact with it appropriately to eliminate class loading loops.

Overrides:
loadClass in class java.lang.ClassLoader
Throws:
java.lang.ClassNotFoundException

getResource

public java.net.URL getResource(java.lang.String name)
Reverses the ordering of the normal ClassLoader.getResource(java.lang.String) method to first search this loader and to delegate only if the resource is not found. This loader is aware of the DelegatingClassLoader and will interact with it appropriately to eliminate class loading loops.

Overrides:
getResource in class java.lang.ClassLoader

getResources

public java.util.Enumeration<java.net.URL> getResources(java.lang.String name)
                                                 throws java.io.IOException
Reverses the ordering of the normal ClassLoader.getResources(java.lang.String) method to first search this loader and to delegate only if no resource can be found. This loader is aware of the DelegatingClassLoader and will interact with it appropriately to eliminate class loading loops.

Overrides:
getResources in class java.lang.ClassLoader
Throws:
java.io.IOException