org.glassfish.internal.api
Class DelegatingClassLoader
java.lang.Object
java.lang.ClassLoader
org.glassfish.internal.api.DelegatingClassLoader
public class DelegatingClassLoader
- extends ClassLoader
This classloader has a list of classloaders called as delegates
that it uses to find classes. All those delegates must have the
same parent as this classloader in order to have a consistent class space.
By consistent class space, I mean a class space where no two loaded class
have same name. An inconsistent class space can lead to ClassCastException.
This classloader does not define any class, classes are always loaded
either by its parent or by one of the delegates.
- Author:
- Sanjeeb.Sahoo@Sun.COM
| 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 |
DelegatingClassLoader
public DelegatingClassLoader(ClassLoader parent,
List<DelegatingClassLoader.ClassFinder> delegates)
throws IllegalArgumentException
- Throws:
IllegalArgumentException - when the delegate does not have same parent
as this classloader.
DelegatingClassLoader
public DelegatingClassLoader(ClassLoader parent)
addDelegate
public boolean addDelegate(DelegatingClassLoader.ClassFinder d)
throws IllegalStateException,
IllegalArgumentException
- Adds a ClassFinder to list of delegates. To have a consistent
class space (by consistent class space, I mean a classpace where there
does not exist two class with same name), this method does not allow
a delegate to be added that has a different parent.
- Parameters:
d - ClassFinder to add to the list of delegates
- Returns:
- true if the delegate is added, false otherwise.
- Throws:
IllegalStateException - when this method is called after the
classloader has been used to load any class.
IllegalArgumentException - when the delegate does not have same parent
as this classloader.
removeDelegate
public boolean removeDelegate(DelegatingClassLoader.ClassFinder d)
- Removes a ClassFinder from list of delegates. This method must not be used
once this classloader has beed used to load any class. If attempted to
do so, this method throws IllegalStateException
- Parameters:
d - ClassFinder to remove from the list of delegates
- Returns:
- true if the delegate was removed, false otherwise.
- Throws:
IllegalStateException - when this method is called after the
classloader has been used to load any class.
findClass
public Class<?> findClass(String name)
throws ClassNotFoundException
- Overrides:
findClass in class ClassLoader
- Throws:
ClassNotFoundException
findResource
protected URL findResource(String name)
- Overrides:
findResource in class ClassLoader
findResources
protected Enumeration<URL> findResources(String name)
throws IOException
- Overrides:
findResources in class ClassLoader
- Throws:
IOException
getName
public String getName()
setName
public void setName(String name)
getDelegates
public List<DelegatingClassLoader.ClassFinder> getDelegates()
toString
public String toString()
- Overrides:
toString in class Object
Copyright © 2012. All Rights Reserved.