org.freecompany.brimstone.module

Class DelegatingClassLoader

public class DelegatingClassLoader extends URLClassLoader

The delegating class loader maintains a list of delegates to which looading commands will be propagated. This list is always traversed in order of insertion.
Field Summary
protected Notificationnotifier
Constructor Summary
DelegatingClassLoader()
Creates an delegating class loader with no parent and no source URLs.
DelegatingClassLoader(ClassLoader parent)
Creates an delegating class loader with no source URLs which uses the provided parent loader.
DelegatingClassLoader(URL[] urls)
Creates an delegating class loader with no parent and with the specified source URLs.
DelegatingClassLoader(URL[] urls, ClassLoader parent)
Creates an delegating class loader with the specified source URLs and which uses the provided parent loader.
Method Summary
voidaddDelegate(ClassLoader loader)
Adds a class loader to the list of delegates.
voidaddUrl(URL url)
Exposes the ability to add locations to this class loader at runtime.
protected Stringdump()
Dumps a string representation of the current threads local stack.
protected Pair<ClassLoader,String>pop()
Pops the Pair on the top of the stack.
protected voidpush(Pair<ClassLoader,String> pair)
Pushes a new Pair onto the thread local stack.
protected booleansearching(String name)
Checks to see if the provided name is currently in the process of being loaded.
protected static StringshortName(Class clazz)
Strips extra characters from a fully qualified class name, leaving only the name within the package.
protected booleanskip(ClassLoader child, String name)
Checks the thread local state to determine whether the provided child needs to be skipped.

Field Detail

notifier

protected Notification notifier

Constructor Detail

DelegatingClassLoader

public DelegatingClassLoader()
Creates an delegating class loader with no parent and no source URLs.

DelegatingClassLoader

public DelegatingClassLoader(ClassLoader parent)
Creates an delegating class loader with no source URLs which uses the provided parent loader.

DelegatingClassLoader

public DelegatingClassLoader(URL[] urls)
Creates an delegating class loader with no parent and with the specified source URLs.

DelegatingClassLoader

public DelegatingClassLoader(URL[] urls, ClassLoader parent)
Creates an delegating class loader with the specified source URLs and which uses the provided parent loader.

Method Detail

addDelegate

public void addDelegate(ClassLoader loader)
Adds a class loader to the list of delegates. Please note that the provided ClassLoader must not have this delegating class loader set as it's parent unless it is an instance of InvertedClassLoader or can otherwise make use of the methods in this loader that take a source as a parameter.

Parameters: loader the ClassLoader to add to the delegate list.

addUrl

public void addUrl(URL url)
Exposes the ability to add locations to this class loader at runtime. This implementation does not promote the existing URLClassLoader#addURL method so as to avoid interfering with normal operation.

Parameters: url the url to add to the list of locations searched for class definitions.

dump

protected final String dump()
Dumps a string representation of the current threads local stack.

Returns: {$link String} representing the current stack state.

pop

protected Pair<ClassLoader,String> pop()
Pops the Pair on the top of the stack.

Returns: the top of the stack if it is not empty.

Throws: EmptyStackException if there are no entries on the stack.

push

protected void push(Pair<ClassLoader,String> pair)
Pushes a new Pair onto the thread local stack.

Parameters: pair the pair of elements describing the latest loading event.

searching

protected boolean searching(String name)
Checks to see if the provided name is currently in the process of being loaded. This indicates that this thread is still within a ClassLoader#loadClass( String) call.

Parameters: name the current class being loaded.

shortName

protected static final String shortName(Class clazz)
Strips extra characters from a fully qualified class name, leaving only the name within the package.

Parameters: clazz the Class for which to construct a short name.

Returns: the class name within its package.

skip

protected boolean skip(ClassLoader child, String name)
Checks the thread local state to determine whether the provided child needs to be skipped.

Parameters: child child class loader to test. name the name of the resource being loaded.

Returns: boolean indicating whether this child should be skipped.