java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
org.dinopolis.util.servicediscovery.RepositoryClassLoader
- public class RepositoryClassLoader
- extends java.net.URLClassLoader
ClassLoader that allows to add all jar files in one or more
repositories (directories). Additionally, a specific directory or a
jar file can be added. This behavior allows to search in
directories for jars even if they are not in the classpath
(e.g. for plugin functionality).
Usage: create an instance of this classloader, add the repositories
and urls the classloader should look for and call the
loadClass method:
RepositoryClassLoader loader = new RepositoryClassLoader();
loader.addRepository("/home/cdaller/plugins");
SuperPlugin plugin = (SuperPlugin)loader.loadClass("org.dinopolis.plugin.SuperPlugin").newInstance();
| Nested classes inherited from class java.lang.ClassLoader |
|
| 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 |
EMPTY_URL_ARRAY
public static final java.net.URL[] EMPTY_URL_ARRAY
- Simple empty URL[0] array.
repositories_
protected java.util.Vector repositories_
RepositoryClassLoader
public RepositoryClassLoader()
- Empty Constructor
RepositoryClassLoader
public RepositoryClassLoader(java.lang.ClassLoader parent)
- Constructor given a parent.
addURL
public void addURL(java.net.URL url)
- Append a URL to this loader's search path.
toString
public java.lang.String toString()
- Produce output suitable for debugging.
addRepository
public void addRepository(java.lang.String repository)
- Add a new repository to the set of places this ClassLoader can look for
classes to be loaded.
addRepository
public void addRepository(java.io.File repository)
- Add a new repository to the set of places this ClassLoader can look
for classes to be loaded. The directory is parsed for ".jar" files
and these jar files are added to the search path. This means that
jars added to the directory after this method was called, are not
used!
getRepositories
public java.util.List getRepositories()
- Returns the repository names (in a list of Strings).