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

Quick Search    Search Deep

org.mortbay.http
Class ContextLoader  view ContextLoader download ContextLoader.java

java.lang.Object
  extended byjava.lang.ClassLoader
      extended byjava.security.SecureClassLoader
          extended byjava.net.URLClassLoader
              extended byorg.mortbay.http.ContextLoader

public class ContextLoader
extends java.net.URLClassLoader

ClassLoader for HttpContext. Specializes URLClassLoader with some utility and file mapping methods. This loader defaults to the 2.3 servlet spec behaviour where non system classes are loaded from the classpath in preference to the parent loader. Java2 compliant loading, where the parent loader always has priority, can be selected with the setJava2Complient method.

Version:
$Id: ContextLoader.java,v 1.21 2003/10/05 23:46:20 gregwilkins Exp $

Nested Class Summary
 
Nested classes inherited from class java.net.URLClassLoader
 
Nested classes inherited from class java.lang.ClassLoader
 
Field Summary
private  boolean _fileClassPathWarning
           
private  boolean _java2compliant
           
private  java.lang.ClassLoader _parent
           
private  java.security.PermissionCollection _permissions
           
private  java.lang.String _urlClassPath
           
private static org.apache.commons.logging.Log log
           
 
Fields inherited from class java.net.URLClassLoader
 
Fields inherited from class java.security.SecureClassLoader
 
Fields inherited from class java.lang.ClassLoader
 
Constructor Summary
ContextLoader(HttpContext context, java.lang.String classPath, java.lang.ClassLoader parent, java.security.PermissionCollection permisions)
          Constructor.
 
Method Summary
 java.security.PermissionCollection getPermissions(java.security.CodeSource cs)
          Returns the permissions needed to access a particular code source.
 java.net.URL getResource(java.lang.String name)
          Get the URL to a resource using this classloader or one of its parents.
 boolean isJava2Compliant()
           
 boolean isSystemPath(java.lang.String name)
           
 java.lang.Class loadClass(java.lang.String name)
          Load a class using this ClassLoader or its parent, without resolving it.
protected  java.lang.Class loadClass(java.lang.String name, boolean resolve)
          Load a class using this ClassLoader or its parent, possibly resolving it as well using resolveClass().
 void setJava2Compliant(boolean compliant)
          Set Java2 compliant status.
 java.lang.String toString()
          Returns a String representation of this URLClassLoader giving the actual Class name, the URLs that are searched and the parent ClassLoader.
 
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findClass, findResource, findResources, 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, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log

_java2compliant

private boolean _java2compliant

_parent

private java.lang.ClassLoader _parent

_permissions

private java.security.PermissionCollection _permissions

_urlClassPath

private java.lang.String _urlClassPath

_fileClassPathWarning

private boolean _fileClassPathWarning
Constructor Detail

ContextLoader

public ContextLoader(HttpContext context,
                     java.lang.String classPath,
                     java.lang.ClassLoader parent,
                     java.security.PermissionCollection permisions)
              throws java.net.MalformedURLException,
                     java.io.IOException
Constructor.

Method Detail

setJava2Compliant

public void setJava2Compliant(boolean compliant)
Set Java2 compliant status.


isJava2Compliant

public boolean isJava2Compliant()

toString

public java.lang.String toString()
Description copied from class: java.net.URLClassLoader
Returns a String representation of this URLClassLoader giving the actual Class name, the URLs that are searched and the parent ClassLoader.


getPermissions

public java.security.PermissionCollection getPermissions(java.security.CodeSource cs)
Description copied from class: java.net.URLClassLoader
Returns the permissions needed to access a particular code source. These permissions includes those returned by SecureClassLoader.getPermissions() and the actual permissions to access the objects referenced by the URL of the code source. The extra permissions added depend on the protocol and file portion of the URL in the code source. If the URL has the "file" protocol ends with a '/' character then it must be a directory and a file Permission to read everything in that directory and all subdirectories is added. If the URL had the "file" protocol and doesn't end with a '/' character then it must be a normal file and a file permission to read that file is added. If the URL has any other protocol then a socket permission to connect and accept connections from the host portion of the URL is added.


loadClass

public java.lang.Class loadClass(java.lang.String name)
                          throws java.lang.ClassNotFoundException
Description copied from class: java.lang.ClassLoader
Load a class using this ClassLoader or its parent, without resolving it. Calls loadClass(name, false).

Subclasses should not override this method but should override findClass() which is called by this method.


loadClass

protected java.lang.Class loadClass(java.lang.String name,
                                    boolean resolve)
                             throws java.lang.ClassNotFoundException
Description copied from class: java.lang.ClassLoader
Load a class using this ClassLoader or its parent, possibly resolving it as well using resolveClass(). It first tries to find out if the class has already been loaded through this classloader by calling findLoadedClass(). Then it calls loadClass() on the parent classloader (or when there is no parent it uses the VM bootclassloader). If the class is still not loaded it tries to create a new class by calling findClass(). Finally when resolve is true it also calls resolveClass() on the newly loaded class.

Subclasses should not override this method but should override findClass() which is called by this method.


getResource

public java.net.URL getResource(java.lang.String name)
Description copied from class: java.lang.ClassLoader
Get the URL to a resource using this classloader or one of its parents. First tries to get the resource by calling getResource() on the parent classloader. If the parent classloader returns null then it tries finding the resource by calling findResource() on this classloader. The resource name should be separated by '/' for path elements.

Subclasses should not override this method but should override findResource() which is called by this method.


isSystemPath

public boolean isSystemPath(java.lang.String name)