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 and Description
`ChildFirstClassLoader(URL[] urls)`
`ChildFirstClassLoader(URL[] urls, ClassLoader parent)`

### Method Summary

Methods
`URL` `getResource(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, findLibrary, findLoadedClass, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### 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:
  `loadClass` in class `ClassLoader`
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:
  `loadClass` in class `ClassLoader`
Parameters:
  `name` - the name of the class to load, should not be `null` .
  `resolve` - 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:
  `getResource` in class `ClassLoader`
Parameters:
  `name` - the name of the resource to load, should not be `null`.
Returns:
  a `URL` for the resource, or `null` if it could not be found.