org.apache.sling.jcr.classloader.internal

## Class RepositoryClassLoader

- java.lang.Object
- - java.lang.ClassLoader
  - - java.security.SecureClassLoader
    - - org.apache.sling.jcr.classloader.internal.RepositoryClassLoader

All Implemented Interfaces:
  org.apache.sling.commons.classloader.DynamicClassLoader

    public final class RepositoryClassLoader
    extends SecureClassLoader
    implements org.apache.sling.commons.classloader.DynamicClassLoader

The `RepositoryClassLoader` class provides the functionality to load classes and resources from the JCR Repository. Additionally, this class supports the notion of getting 'dirty', which means, that if a resource loaded through this class loader has been modified in the repository, this class loader marks itself dirty, which flag can get retrieved.

### Constructor Summary

Constructors
Constructor and Description
`RepositoryClassLoader(String classPath, ClassLoaderWriterImpl writer, ClassLoader parent)` Creates a `RepositoryClassLoader` for a given repository path.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `destroy()` Destroys this class loader.
`protected Class<?>` `findClass(String name)` Finds and loads the class with the specified name from the class path.
`URL` `findResource(String name)` Finds the resource with the specified name on the search path.
`Enumeration<URL>` `findResources(String name)` Returns an Enumeration of URLs representing all of the resources on the search path having the specified name.
`void` `handleEvent(String path)` Handle a modification event.
`boolean` `isLive()`
`String` `toString()` Returns a string representation of this class loader.

### Methods inherited from class java.security.SecureClassLoader

`defineClass, defineClass, getPermissions`

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

`clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners`

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

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

### Constructor Detail

#### RepositoryClassLoader

    public RepositoryClassLoader(String classPath,
                                 ClassLoaderWriterImpl writer,
                                 ClassLoader parent)

Creates a `RepositoryClassLoader` for a given repository path.

Parameters:
  `classPath` - The path making up the class path of this class loader
  `writer` - The class loader write to get a jcr session.
  `parent` - The parent `ClassLoader`, which may be `null`.
Throws:
  `NullPointerException` - if either the session or the classPath is `null`.

### Method Detail

#### destroy

    public void destroy()

Destroys this class loader. This process encompasses all steps needed to remove as much references to this class loader as possible.

NOTE: This method just clears all internal fields and especially the class path to render this class loader unusable.

This implementation does not throw any exceptions.

#### findClass

    protected Class<?> findClass(String name)
                          throws ClassNotFoundException

Finds and loads the class with the specified name from the class path.

Overrides:
  `findClass` in class `ClassLoader`
Parameters:
  `name` - the name of the class
Returns:
  the resulting class
Throws:
  `ClassNotFoundException` - If the named class could not be found or if this class loader has already been destroyed.

#### findResource

    public URL findResource(String name)

Finds the resource with the specified name on the search path.

Overrides:
  `findResource` in class `ClassLoader`
Parameters:
  `name` - the name of the resource
Returns:
  a `URL` for the resource, or `null` if the resource could not be found or if the class loader has already been destroyed.

#### findResources

    public Enumeration<URL> findResources(String name)

Returns an Enumeration of URLs representing all of the resources on the search path having the specified name.

Overrides:
  `findResources` in class `ClassLoader`
Parameters:
  `name` - the resource name
Returns:
  an `Enumeration` of `URL`s. This is an empty enumeration if no resources are found by this class loader or if this class loader has already been destroyed.

#### isLive

    public boolean isLive()

Specified by:
  `isLive` in interface `org.apache.sling.commons.classloader.DynamicClassLoader`
See Also:
  `DynamicClassLoader.isLive()`

#### handleEvent

    public void handleEvent(String path)

Handle a modification event.

#### toString

    public String toString()

Returns a string representation of this class loader.

Overrides:
  `toString` in class `Object`