|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
org.homeunix.thecave.moss.classpath.MutableClassLoader
public class MutableClassLoader
Mutable class loader, which allows you to load additional jar files at runtime, via the addURL() method. Most people would want to run this initially from their main method, and use it to load other jars as needed. This class loader also provides other useful meathods, such as the ability to return a list of all classes which implement / extend a given interface / class. This can, for instance, be useful for automatic discovery of plugins at runtime.
| Nested Class Summary | |
|---|---|
static class |
MutableClassLoader.MutableClassLoaderException
An exception which is thrown by MutableClassLoader. |
| Constructor Summary | |
|---|---|
MutableClassLoader()
Creates a new instance of ExtensibleClassLoader, with a parent delegate of the system class loader. |
|
MutableClassLoader(java.net.URL[] urls)
Creates a new instance of ExtensibleClassLoader, with a parent delegate of the system class loader, and load all specified URLs. |
|
| Method Summary | |
|---|---|
void |
addURL(java.net.URL url)
Adds the URL to the current classpath, if it has not already been added. |
java.net.URL[] |
getAddedURLs()
Returns all the URLs which have been added via the addURL() method. |
java.util.List<java.lang.Class<?>> |
getImplementingClasses(java.lang.Class<?> ancestor,
boolean searchAllClasspath)
Returns all classes in the current class path (system class path plus any added URLs) which are descendents of or implement the given class / interface. |
java.util.List<?> |
getImplementingObjects(java.lang.Class<?> c,
java.lang.Object... constructorAguments)
Returns a list of instantiated obejcts, all of which are instances of the given class. |
java.net.URL[] |
getURLs()
Returns all the URLs which were initially in the classpath, and which have been added via the addURL() method. |
java.lang.Object |
newInstance(java.lang.Class<?> c,
java.lang.Object... arguments)
Instantiates a new object of the specified class, using the constructor which matches the given arguments. |
java.lang.Object |
newInstance(java.lang.String className,
java.lang.Object... arguments)
Instantiates a new object of the specified class name, using the constructor which matches the given arguments. |
| Methods inherited from class java.net.URLClassLoader |
|---|
definePackage, findClass, findResource, findResources, getPermissions, 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, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, 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 |
|---|
public MutableClassLoader()
public MutableClassLoader(java.net.URL[] urls)
urls - URLs of resources to load initially. Equivalent to calling
the default constructor, and calling addURL() for each of the URLs.| Method Detail |
|---|
public void addURL(java.net.URL url)
addURL in class java.net.URLClassLoader
public java.lang.Object newInstance(java.lang.Class<?> c,
java.lang.Object... arguments)
throws MutableClassLoader.MutableClassLoaderException
c - The class to loadarguments - An array of the arguments to the desired constructor
MutableClassLoader.MutableClassLoaderException
public java.lang.Object newInstance(java.lang.String className,
java.lang.Object... arguments)
throws MutableClassLoader.MutableClassLoaderException
className - The class name to loadarguments - An array of the arguments to the desired constructor
MutableClassLoader.MutableClassLoaderException
public java.util.List<java.lang.Class<?>> getImplementingClasses(java.lang.Class<?> ancestor,
boolean searchAllClasspath)
throws MutableClassLoader.MutableClassLoaderException
ancestor - The class or interface to check against.
MutableClassLoader.MutableClassLoaderException
public java.util.List<?> getImplementingObjects(java.lang.Class<?> c,
java.lang.Object... constructorAguments)
c - constructorAguments -
public java.net.URL[] getURLs()
getURLs in class java.net.URLClassLoaderpublic java.net.URL[] getAddedURLs()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||