Class DynamicClassLoader

This class extends ClassLoader, but allows for new jars/classpath elements
to be added at runtime. Note that already loaded classes won't be affected
if a new jar is added, but new requests for classes will be.

Constructor Detail

DynamicClassLoader

Method Detail

addJar

Adds a jar to this class loader instance. This can be done at runtime,
however note that jars cannot be removed, and if a jar already defines
a class (or the class has already been loaded) it cannot be changed inside this
instance. Adding the same URL twice has no effect.

Parameters:

url - The url to the jar.

loadClass

destroy

public void destroy()

When this class is no longer needed, this method can be called
to destroy all the internal references and "lock" the class for
future use. If any method (other than destroy) is attempted to be
called in this instance after this method is called, it will throw
a runtime exception, which should hopefully help catch errors faster.