Package org.jboss.util.loading
Class DelegatingClassLoader
- java.lang.Object
-
- java.lang.ClassLoader
-
- java.security.SecureClassLoader
-
- java.net.URLClassLoader
-
- org.jboss.util.loading.DelegatingClassLoader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class DelegatingClassLoader extends java.net.URLClassLoader
A URL classloader that delegates to its parent, avoiding synchronization. A standard flag is provided so it can be used as a parent class, but later subclassed and to revert to standard class loading if the subclass wants to load classes.- Version:
- $Revision$
-
-
Field Summary
Fields Modifier and Type Field Description static java.net.URL[]
EMPTY_URL_ARRAY
The value returned byURLClassLoader.getURLs()
.private java.lang.ClassLoader
parent
Cache the parentprotected boolean
standard
Whether to use standard loading
-
Constructor Summary
Constructors Constructor Description DelegatingClassLoader(java.lang.ClassLoader parent)
ConstructorDelegatingClassLoader(java.lang.ClassLoader parent, java.net.URLStreamHandlerFactory factory)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Class<?>
loadClass(java.lang.String className, boolean resolve)
Load a class, by asking the parent-
Methods inherited from class java.net.URLClassLoader
addURL, close, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
-
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
-
-
-
Constructor Detail
-
DelegatingClassLoader
public DelegatingClassLoader(java.lang.ClassLoader parent)
Constructor- Parameters:
parent
- the parent classloader, cannot be null.
-
DelegatingClassLoader
public DelegatingClassLoader(java.lang.ClassLoader parent, java.net.URLStreamHandlerFactory factory)
Constructor- Parameters:
parent
- the parent classloader, cannot be null.factory
- the url stream factory.
-
-
Method Detail
-
loadClass
protected java.lang.Class<?> loadClass(java.lang.String className, boolean resolve) throws java.lang.ClassNotFoundException
Load a class, by asking the parent- Overrides:
loadClass
in classjava.lang.ClassLoader
- Parameters:
className
- the class name to loadresolve
- whether to link the class- Returns:
- the loaded class
- Throws:
java.lang.ClassNotFoundException
- when the class could not be found
-
-