org.ckkloverdos.util
Class CompositeClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by org.ckkloverdos.util.CompositeClassLoader
All Implemented Interfaces:
IToStringAware

public class CompositeClassLoader
extends java.lang.ClassLoader
implements IToStringAware

An extensible classloader that delegates class loading to a list of other class loaders.

Author:
Christos KK Loverdos

Constructor Summary
CompositeClassLoader()
          Constructs a new instance with the context class loader as the parent.
CompositeClassLoader(java.lang.ClassLoader parent)
          Constructs a new instance with the given parent.
CompositeClassLoader(java.lang.ClassLoader[] loaders)
          Constructs a new instance with the given array of class loaders.
CompositeClassLoader(java.util.List loaders)
          Constructs a new instance with the given list of class loaders.
 
Method Summary
 void add(java.lang.ClassLoader l)
          Adds the given class loader to the end of the internal list of class loaders.
 void add(java.io.File f)
           
 void add(java.net.URI uri)
          Creates a new URLClassLoader and adds it to the end of the internal list of class loaders.
 void add(java.net.URI[] uris)
          Creates a new URLClassLoader and adds it to the end of the internal list of class loaders.
 void add(java.net.URL url)
          Creates a new URLClassLoader and adds it to the end of the internal list of class loaders.
 void add(java.net.URL[] urls)
          Creates a new URLClassLoader and adds it to the end of the internal list of class loaders.
 void addFile(java.lang.String filename)
           
protected  java.lang.Class findClass(java.lang.String s)
           
 java.lang.ClassLoader[] getClassLoaders()
           
 boolean remove(java.lang.ClassLoader l)
           
 void setAsContextClassLoader()
          Sets this class loader as the context class loader.
 java.lang.String toString()
           
 void toStringAware(ToString ts)
           
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findResource, findResources, 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
 

Constructor Detail

CompositeClassLoader

public CompositeClassLoader(java.lang.ClassLoader parent)
Constructs a new instance with the given parent.

Parameters:
parent -

CompositeClassLoader

public CompositeClassLoader()
Constructs a new instance with the context class loader as the parent.


CompositeClassLoader

public CompositeClassLoader(java.util.List loaders)
Constructs a new instance with the given list of class loaders.

Parameters:
loaders -

CompositeClassLoader

public CompositeClassLoader(java.lang.ClassLoader[] loaders)
Constructs a new instance with the given array of class loaders.

Parameters:
loaders -
Method Detail

add

public void add(java.lang.ClassLoader l)
Adds the given class loader to the end of the internal list of class loaders.

Parameters:
l -

add

public void add(java.net.URL url)
Creates a new URLClassLoader and adds it to the end of the internal list of class loaders.

Parameters:
url -

add

public void add(java.net.URL[] urls)
Creates a new URLClassLoader and adds it to the end of the internal list of class loaders.

Parameters:
urls -

add

public void add(java.net.URI[] uris)
         throws java.net.MalformedURLException
Creates a new URLClassLoader and adds it to the end of the internal list of class loaders. The URIs are first translated to URLs.

Parameters:
uris -
Throws:
java.net.MalformedURLException

add

public void add(java.net.URI uri)
         throws java.net.MalformedURLException
Creates a new URLClassLoader and adds it to the end of the internal list of class loaders.

Parameters:
uri -
Throws:
java.net.MalformedURLException

add

public void add(java.io.File f)

addFile

public void addFile(java.lang.String filename)

remove

public boolean remove(java.lang.ClassLoader l)

getClassLoaders

public java.lang.ClassLoader[] getClassLoaders()

setAsContextClassLoader

public void setAsContextClassLoader()
Sets this class loader as the context class loader.


findClass

protected java.lang.Class findClass(java.lang.String s)
                             throws java.lang.ClassNotFoundException
Overrides:
findClass in class java.lang.ClassLoader
Throws:
java.lang.ClassNotFoundException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toStringAware

public void toStringAware(ToString ts)
Specified by:
toStringAware in interface IToStringAware


Copyright © 1999-2007 Christos KK Loverdos. All Rights Reserved.