Package org.glassfish.internal.api
Class DelegatingClassLoader
java.lang.Object
java.lang.ClassLoader
org.glassfish.internal.api.DelegatingClassLoader
This class loader has a list of class loaders called as delegates
that it uses to find classes.
All those delegates must have the same parent as this class loader in order to
have a consistent class space. By consistent class space, we mean a class space
where no two loaded class have same name. An inconsistent class space can lead
to ClassCastException.
This class loader does not define any class, classes are always loaded either by its parent or by one of the delegates.
- Author:
- Sanjeeb.Sahoo@Sun.COM
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThis interface is an optimization. -
Constructor Summary
ConstructorsConstructorDescriptionDelegatingClassLoader(ClassLoader parent) DelegatingClassLoader(ClassLoader parent, List<DelegatingClassLoader.ClassFinder> delegates) Creates new delegating class loader. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddDelegate(DelegatingClassLoader.ClassFinder classFinder) Adds a class finder to list of delegates.Class<?> protected URLfindResource(String name) protected Enumeration<URL> findResources(String name) getName()booleanremoveDelegate(DelegatingClassLoader.ClassFinder classFinder) Removes a class finder from list of delegates.voidtoString()Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Constructor Details
-
DelegatingClassLoader
Creates new delegating class loader.- Throws:
IllegalArgumentException- when the delegate does not have same parent as this class loader
-
DelegatingClassLoader
-
-
Method Details
-
addDelegate
Adds a class finder to list of delegates.To have a consistent class space (by consistent class space, we mean a class space 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:
classFinder- class finder to add to the list of delegates- Returns:
trueif the delegate is added,falseotherwise- Throws:
IllegalArgumentException- when the delegate does not have same parent as this class loader
-
removeDelegate
Removes a class finder from list of delegates.- Parameters:
classFinder- class finder to remove from the list of delegates- Returns:
trueif the delegate was removed,falseotherwise
-
findClass
- Overrides:
findClassin classClassLoader- Throws:
ClassNotFoundException
-
findResource
- Overrides:
findResourcein classClassLoader
-
findResources
- Overrides:
findResourcesin classClassLoader- Throws:
IOException
-
getName
- Overrides:
getNamein classClassLoader
-
setName
-
getDelegates
-
toString
-