FileDocCategorySizeDatePackage
VirtualWebappLoader.javaAPI DocApache Tomcat 6.0.143607Fri Jul 20 04:20:34 BST 2007org.apache.catalina.loader

VirtualWebappLoader

public class VirtualWebappLoader extends WebappLoader
Simple webapp classloader that allows a customized classpath to be added through configuration in context xml. Any additional classpath entry will be added to the default webapp classpath, making easy to emulate a standard webapp without the need for assembly all the webapp dependencies as jars in WEB-INF/lib. <Context docBase="\webapps\mydocbase"> <Loader className="org.apache.catalina.loader.VirtualWebappLoader" virtualClasspath="\dir\classes;\somedir\somejar.jar"/> </Context> This is not meant to be used for production. Its meant to ease development with IDE's without the need for fully republishing jars in WEB-INF/lib
author
Fabrizio Giustina
version
$Id: $

Fields Summary
private String
virtualClasspath
; separated list of additional path elements.
Constructors Summary
public VirtualWebappLoader()
Construct a new WebappLoader with no defined parent class loader (so that the actual parent will be the system class loader).

        super();
    
public VirtualWebappLoader(ClassLoader parent)
Construct a new WebappLoader with the specified class loader to be defined as the parent of the ClassLoader we ultimately create.

param
parent The parent class loader

        super(parent);
    
Methods Summary
public voidsetVirtualClasspath(java.lang.String path)
virtualClasspath attribute that will be automatically set from the Context virtualClasspath attribute from the context xml file.

param
path ; separated list of path elements.

        virtualClasspath = path;
    
public voidstart()


        // just add any jar/directory set in virtual classpath to the
        // repositories list before calling start on the standard WebappLoader
        StringTokenizer tkn = new StringTokenizer(virtualClasspath, ";");
        while (tkn.hasMoreTokens()) {
            File file = new File(tkn.nextToken());
            if (!file.exists()) {
                continue;
            }
            if (file.isDirectory()) {
                addRepository("file:/" + file.getAbsolutePath() + "/");
            } else {
                addRepository("file:/" + file.getAbsolutePath());
            }
        }

        super.start();