# Interface Loader

All Known Implementing Classes:
  `WebappLoader`

public interface Loader
A Loader represents a Java ClassLoader implementation that can be used by a Container to load class files (within a repository associated with the Loader) that are designed to be reloaded upon request, as well as a mechanism to detect whether changes have occurred in the underlying repository.

In order for a `Loader` implementation to successfully operate with a `Context` implementation that implements reloading, it must obey the following constraints:

- Must implement `Lifecycle` so that the Context can indicate that a new class loader is required.
- The `start()` method must unconditionally create a new `ClassLoader` implementation.
- The `stop()` method must throw away its reference to the `ClassLoader` previously utilized, so that the class loader, all classes loaded by it, and all objects of those classes, can be garbage collected.
- Must allow a call to `stop()` to be followed by a call to `start()` on the same `Loader` instance.
- Based on a policy chosen by the implementation, must call the `Context.reload()` method on the owning `Context` when a change to one or more of the class files loaded by this class loader is detected.

Author:
  Craig R. McClanahan

## Method Summary

Modifier and Type
Method
Description
`void`
`addPropertyChangeListener(PropertyChangeListener listener)`
Add a property change listener to this component.
`void`
`backgroundProcess()`
Execute a periodic task, such as reloading, etc.
`ClassLoader`
`getClassLoader()`
`Context`
`getContext()`
`boolean`
`getDelegate()`
`boolean`
`modified()`
Has the internal repository associated with this Loader been modified, such that the loaded classes should be reloaded?
`void`
`removePropertyChangeListener(PropertyChangeListener listener)`
Remove a property change listener from this component.
`void`
`setContext(Context context)`
Set the Context with which this Loader has been associated.
`void`
`setDelegate(boolean delegate)`
Set the "follow standard delegation model" flag used to configure our ClassLoader.

## Method Details

### backgroundProcess

void backgroundProcess()
Execute a periodic task, such as reloading, etc. This method will be invoked inside the classloading context of this container. Unexpected throwables will be caught and logged.

### getClassLoader

ClassLoader getClassLoader()

Returns:
  the Java class loader to be used by this Loader.

### getContext

Context getContext()

Returns:
  the Context with which this Loader has been associated.

### setContext

void setContext(Context context)
Set the Context with which this Loader has been associated.

Parameters:
  `context` - The associated Context

### getDelegate

boolean getDelegate()

Returns:
  the "follow standard delegation model" flag used to configure our ClassLoader.

### setDelegate

void setDelegate(boolean delegate)
Set the "follow standard delegation model" flag used to configure our ClassLoader.

Parameters:
  `delegate` - The new flag

### addPropertyChangeListener

void addPropertyChangeListener(PropertyChangeListener listener)
Add a property change listener to this component.

Parameters:
  `listener` - The listener to add

### modified

boolean modified()
Has the internal repository associated with this Loader been modified, such that the loaded classes should be reloaded?

Returns:
  `true` when the repository has been modified, `false` otherwise

### removePropertyChangeListener

void removePropertyChangeListener(PropertyChangeListener listener)
Remove a property change listener from this component.

Parameters:
  `listener` - The listener to remove