org.apache.xbean.server.classloader
Class MultiParentClassLoader

java.lang.Object
  extended byjava.lang.ClassLoader
      extended byjava.security.SecureClassLoader
          extended byjava.net.URLClassLoader
              extended byorg.apache.xbean.server.classloader.NamedClassLoader
                  extended byorg.apache.xbean.server.classloader.MultiParentClassLoader
All Implemented Interfaces:
DestroyableClassLoader
Direct Known Subclasses:
JarFileClassLoader

public class MultiParentClassLoader
extends NamedClassLoader

A MultiParentClassLoader is a simple extension of the URLClassLoader that simply changes the single parent class loader model to support a list of parent class loaders. Each operation that accesses a parent, has been replaced with a operation that checks each parent in order. This getParent method of this class will always return null, which may be interperated by the calling code to mean that this class loader is a direct child of the system class loader.

Since:
2.0
Version:
$Id$
Author:
Dain Sundstrom

Constructor Summary
MultiParentClassLoader(java.lang.String name, java.net.URL[] urls)
          Creates a named class loader with no parents.
MultiParentClassLoader(java.lang.String name, java.net.URL[] urls, java.lang.ClassLoader parent)
          Creates a named class loader as a child of the specified parent.
MultiParentClassLoader(java.lang.String name, java.net.URL[] urls, java.lang.ClassLoader[] parents)
          Creates a named class loader as a child of the specified parents.
MultiParentClassLoader(java.lang.String name, java.net.URL[] urls, java.lang.ClassLoader[] parents, java.net.URLStreamHandlerFactory factory)
          Creates a named class loader as a child of the specified parents and using the specified URLStreamHandlerFactory for accessing the urls..
MultiParentClassLoader(java.lang.String name, java.net.URL[] urls, java.lang.ClassLoader parent, java.net.URLStreamHandlerFactory factory)
          Creates a named class loader as a child of the specified parent and using the specified URLStreamHandlerFactory for accessing the urls..
 
Method Summary
 java.util.Enumeration findResources(java.lang.String name)
          
 java.lang.ClassLoader[] getParents()
          Gets the parents of this class loader.
 java.net.URL getResource(java.lang.String name)
          
protected  java.lang.Class loadClass(java.lang.String name, boolean resolve)
          
 java.lang.String toString()
          
 
Methods inherited from class org.apache.xbean.server.classloader.NamedClassLoader
destroy, getName
 
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findClass, findResource, getPermissions, getURLs, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, 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

MultiParentClassLoader

public MultiParentClassLoader(java.lang.String name,
                              java.net.URL[] urls)
Creates a named class loader with no parents.

Parameters:
name - the name of this class loader
urls - the urls from which this class loader will classes and resources

MultiParentClassLoader

public MultiParentClassLoader(java.lang.String name,
                              java.net.URL[] urls,
                              java.lang.ClassLoader parent)
Creates a named class loader as a child of the specified parent.

Parameters:
name - the name of this class loader
urls - the urls from which this class loader will classes and resources
parent - the parent of this class loader

MultiParentClassLoader

public MultiParentClassLoader(java.lang.String name,
                              java.net.URL[] urls,
                              java.lang.ClassLoader parent,
                              java.net.URLStreamHandlerFactory factory)
Creates a named class loader as a child of the specified parent and using the specified URLStreamHandlerFactory for accessing the urls..

Parameters:
name - the name of this class loader
urls - the urls from which this class loader will classes and resources
parent - the parent of this class loader
factory - the URLStreamHandlerFactory used to access the urls

MultiParentClassLoader

public MultiParentClassLoader(java.lang.String name,
                              java.net.URL[] urls,
                              java.lang.ClassLoader[] parents)
Creates a named class loader as a child of the specified parents.

Parameters:
name - the name of this class loader
urls - the urls from which this class loader will classes and resources
parents - the parents of this class loader

MultiParentClassLoader

public MultiParentClassLoader(java.lang.String name,
                              java.net.URL[] urls,
                              java.lang.ClassLoader[] parents,
                              java.net.URLStreamHandlerFactory factory)
Creates a named class loader as a child of the specified parents and using the specified URLStreamHandlerFactory for accessing the urls..

Parameters:
name - the name of this class loader
urls - the urls from which this class loader will classes and resources
parents - the parents of this class loader
factory - the URLStreamHandlerFactory used to access the urls
Method Detail

getParents

public java.lang.ClassLoader[] getParents()
Gets the parents of this class loader.

Returns:
the parents of this class loader

loadClass

protected java.lang.Class loadClass(java.lang.String name,
                                    boolean resolve)
                             throws java.lang.ClassNotFoundException

Throws:
java.lang.ClassNotFoundException

getResource

public java.net.URL getResource(java.lang.String name)


findResources

public java.util.Enumeration findResources(java.lang.String name)
                                    throws java.io.IOException

Throws:
java.io.IOException

toString

public java.lang.String toString()

Overrides:
toString in class NamedClassLoader


Copyright © {inceptionYear}-2006 Apache Software Foundation. All Rights Reserved.