Package org.red5.classloading
Class ChildFirstClassLoader
- java.lang.Object
-
- java.lang.ClassLoader
-
- java.security.SecureClassLoader
-
- java.net.URLClassLoader
-
- org.red5.classloading.ChildFirstClassLoader
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public final class ChildFirstClassLoader extends URLClassLoader
An almost trivial no-fuss implementation of a class loader following the child-first delegation model. Based on code from Ceki Gulcu- Author:
- Paul Gregoire (mondain@gmail.com)
-
-
Constructor Summary
Constructors Constructor Description ChildFirstClassLoader(URL[] urls)ChildFirstClassLoader(URL[] urls, ClassLoader parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description URLgetResource(String name)Override the parent-first resource loading model established by java.lang.Classloader with child-first behavior.Class<?>loadClass(String name)protected Class<?>loadClass(String name, boolean resolve)We override the parent-first behavior established by java.lang.Classloader.-
Methods inherited from class java.net.URLClassLoader
addURL, close, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, 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, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
-
-
-
Constructor Detail
-
ChildFirstClassLoader
public ChildFirstClassLoader(URL[] urls)
-
ChildFirstClassLoader
public ChildFirstClassLoader(URL[] urls, ClassLoader parent)
-
-
Method Detail
-
loadClass
public Class<?> loadClass(String name) throws ClassNotFoundException
- Overrides:
loadClassin classClassLoader- Throws:
ClassNotFoundException
-
loadClass
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
We override the parent-first behavior established by java.lang.Classloader.The implementation is surprisingly straightforward.
- Overrides:
loadClassin classClassLoader- Parameters:
name- the name of the class to load, should not be nullresolve- flag that indicates whether the class should be resolved- Returns:
- the loaded class, never null
- Throws:
ClassNotFoundException- if the class could not be loaded
-
getResource
public URL getResource(String name)
Override the parent-first resource loading model established by java.lang.Classloader with child-first behavior.- Overrides:
getResourcein classClassLoader- Parameters:
name- the name of the resource to load, should not be null- Returns:
- a
URLfor the resource, or null if it could not be found
-
-