org.mortbay.jetty.webapp
Class WebAppClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by org.mortbay.jetty.webapp.WebAppClassLoader
All Implemented Interfaces:
Cloneable

public class WebAppClassLoader
extends URLClassLoader
implements Cloneable

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 WebAppContext.setParentLoaderPriority(boolean) method. If no parent class loader is provided, then the current thread context classloader will be used. If that is null then the classloader that loaded this class is used as the parent.

Author:
Greg Wilkins (gregw)

Constructor Summary
WebAppClassLoader(ClassLoader parent, WebAppContext context)
          Constructor.
WebAppClassLoader(WebAppContext context)
          Constructor.
 
Method Summary
 void addClassPath(String classPath)
           
 void addJars(Resource lib)
          Add elements to the class path for the context from the jar and zip files found in the specified resource.
 Object clone()
           
 void destroy()
           
 WebAppContext getContext()
           
 PermissionCollection getPermissions(CodeSource cs)
           
 URL getResource(String name)
           
 boolean isServerPath(String name)
           
 boolean isSystemPath(String name)
           
 Class loadClass(String name)
           
protected  Class loadClass(String name, boolean resolve)
           
 String toString()
           
 
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findClass, findResource, findResources, getURLs, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass, 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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WebAppClassLoader

public WebAppClassLoader(WebAppContext context)
                  throws IOException
Constructor.

Throws:
IOException

WebAppClassLoader

public WebAppClassLoader(ClassLoader parent,
                         WebAppContext context)
                  throws IOException
Constructor.

Throws:
IOException
Method Detail

clone

public Object clone()
             throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException

getContext

public WebAppContext getContext()

addClassPath

public void addClassPath(String classPath)
                  throws IOException
Parameters:
classPath - Comma or semicolon separated path of filenames or URLs pointing to directories or jar files. Directories should end with '/'.
Throws:
IOException

addJars

public void addJars(Resource lib)
Add elements to the class path for the context from the jar and zip files found in the specified resource.

Parameters:
lib - the resource that contains the jar and/or zip files.
append - true if the classpath entries are to be appended to any existing classpath, or false if they replace the existing classpath.
See Also:
#setClassPath(String)

destroy

public void destroy()

getPermissions

public PermissionCollection getPermissions(CodeSource cs)
Overrides:
getPermissions in class URLClassLoader

getResource

public URL getResource(String name)
Overrides:
getResource in class ClassLoader

isServerPath

public boolean isServerPath(String name)

isSystemPath

public boolean isSystemPath(String name)

loadClass

public Class loadClass(String name)
                throws ClassNotFoundException
Overrides:
loadClass in class ClassLoader
Throws:
ClassNotFoundException

loadClass

protected Class loadClass(String name,
                          boolean resolve)
                   throws ClassNotFoundException
Overrides:
loadClass in class ClassLoader
Throws:
ClassNotFoundException

toString

public String toString()
Overrides:
toString in class Object