org.apache.cocoon.servlet
Class ParanoidClassLoader

java.lang.Object
  |
  +--java.lang.ClassLoader
        |
        +--java.security.SecureClassLoader
              |
              +--java.net.URLClassLoader
                    |
                    +--org.apache.cocoon.servlet.ParanoidClassLoader

public class ParanoidClassLoader
extends java.net.URLClassLoader

The ParanoidClassLoader reverses the search order for classes. It checks this classloader before it checks its parent.

Version:
CVS $Id: ParanoidClassLoader.java,v 1.5 2002/03/20 11:00:06 sylvain Exp $
Author:
Berin Loritsch, Sylvain Wallez

Constructor Summary
ParanoidClassLoader()
          Default constructor has no parents or initial URLs.
ParanoidClassLoader(java.lang.ClassLoader parent)
          Alternate constructor to define a parent.
ParanoidClassLoader(java.net.URL[] urls)
          Alternate constructor to define initial URLs.
ParanoidClassLoader(java.net.URL[] urls, java.lang.ClassLoader parent)
          Alternate constructor to define a parent and initial URLs.
ParanoidClassLoader(java.net.URL[] urls, java.lang.ClassLoader parent, java.net.URLStreamHandlerFactory factory)
          Alternate constructor to define a parent, initial URLs, and a default URLStreamHandlerFactory.
 
Method Summary
 void addDirectory(java.io.File file)
          Adds a new directory of class files.
 java.net.URL getResource(java.lang.String name)
          Gets a resource from this ClassLoader.
 java.lang.Class loadClass(java.lang.String name, boolean resolve)
          Loads the class from this ClassLoader.
static java.net.URLClassLoader newInstance(java.net.URL[] urls)
          Extends URLClassLoader's initialization methods so we return a ParanoidClassLoad instead.
static java.net.URLClassLoader newInstance(java.net.URL[] urls, java.lang.ClassLoader parent)
          Extends URLClassLoader's initialization methods so we return a ParanoidClassLoad instead.
 
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findClass, findResource, findResources, getPermissions, getURLs
 
Methods inherited from class java.security.SecureClassLoader
defineClass
 
Methods inherited from class java.lang.ClassLoader
defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParanoidClassLoader

public ParanoidClassLoader()
Default constructor has no parents or initial URLs.

ParanoidClassLoader

public ParanoidClassLoader(java.lang.ClassLoader parent)
Alternate constructor to define a parent.

ParanoidClassLoader

public ParanoidClassLoader(java.net.URL[] urls)
Alternate constructor to define initial URLs.

ParanoidClassLoader

public ParanoidClassLoader(java.net.URL[] urls,
                           java.lang.ClassLoader parent)
Alternate constructor to define a parent and initial URLs.

ParanoidClassLoader

public ParanoidClassLoader(java.net.URL[] urls,
                           java.lang.ClassLoader parent,
                           java.net.URLStreamHandlerFactory factory)
Alternate constructor to define a parent, initial URLs, and a default URLStreamHandlerFactory.
Method Detail

newInstance

public static final java.net.URLClassLoader newInstance(java.net.URL[] urls)
Extends URLClassLoader's initialization methods so we return a ParanoidClassLoad instead.

newInstance

public static final java.net.URLClassLoader newInstance(java.net.URL[] urls,
                                                        java.lang.ClassLoader parent)
Extends URLClassLoader's initialization methods so we return a ParanoidClassLoad instead.

loadClass

public final java.lang.Class loadClass(java.lang.String name,
                                       boolean resolve)
                                throws java.lang.ClassNotFoundException
Loads the class from this ClassLoader. If the class does not exist in this one, we check the parent. Please note that this is the exact opposite of the ClassLoader spec. We use it to work around inconsistent class loaders from third party vendors.
Overrides:
loadClass in class java.lang.ClassLoader
Parameters:
name - the name of the class
resolve - if true then resolve the class
Returns:
the resulting Class object
Throws:
java.lang.ClassNotFoundException - if the class could not be found

getResource

public final java.net.URL getResource(java.lang.String name)
Gets a resource from this ClassLoader. If the resource does not exist in this one, we check the parent. Please note that this is the exact opposite of the ClassLoader spec. We use it to work around inconsistent class loaders from third party vendors.
Overrides:
getResource in class java.lang.ClassLoader
Parameters:
name - of resource

addDirectory

public final void addDirectory(java.io.File file)
                        throws java.io.IOException
Adds a new directory of class files.
Parameters:
file - for jar or directory
Throws:
java.io.IOException -  


Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.