Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.dinopolis.util.servicediscovery
Class RepositoryClassLoader  view RepositoryClassLoader download RepositoryClassLoader.java

java.lang.Object
  extended byjava.lang.ClassLoader
      extended byjava.security.SecureClassLoader
          extended byjava.net.URLClassLoader
              extended byorg.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 Class Summary
 
Nested classes inherited from class java.net.URLClassLoader
 
Nested classes inherited from class java.lang.ClassLoader
 
Field Summary
static java.net.URL[] EMPTY_URL_ARRAY
          Simple empty URL[0] array.
protected  java.util.Vector repositories_
           
 
Fields inherited from class java.net.URLClassLoader
 
Fields inherited from class java.security.SecureClassLoader
 
Fields inherited from class java.lang.ClassLoader
 
Constructor Summary
RepositoryClassLoader()
          Empty Constructor
RepositoryClassLoader(java.lang.ClassLoader parent)
          Constructor given a parent.
 
Method Summary
 void addRepository(java.io.File repository)
          Add a new repository to the set of places this ClassLoader can look for classes to be loaded.
 void addRepository(java.lang.String repository)
          Add a new repository to the set of places this ClassLoader can look for classes to be loaded.
 void addURL(java.net.URL url)
          Append a URL to this loader's search path.
 java.util.List getRepositories()
          Returns the repository names (in a list of Strings).
 java.lang.String toString()
          Produce output suitable for debugging.
 
Methods inherited from class java.net.URLClassLoader
definePackage, findClass, findResource, findResources, getPermissions, getURLs, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
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, wait, wait, wait
 

Field Detail

EMPTY_URL_ARRAY

public static final java.net.URL[] EMPTY_URL_ARRAY
Simple empty URL[0] array.


repositories_

protected java.util.Vector repositories_
Constructor Detail

RepositoryClassLoader

public RepositoryClassLoader()
Empty Constructor


RepositoryClassLoader

public RepositoryClassLoader(java.lang.ClassLoader parent)
Constructor given a parent.

Method Detail

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).