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 newClassLoader
implementation. - The
stop()
method must throw away its reference to theClassLoader
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 tostart()
on the sameLoader
instance. - Based on a policy chosen by the implementation, must call the
Context.reload()
method on the owningContext
when a change to one or more of the class files loaded by this class loader is detected.