org.eclipse.jetty.webapp
Class WebInfConfiguration

java.lang.Object
  extended by org.eclipse.jetty.webapp.AbstractConfiguration
      extended by org.eclipse.jetty.webapp.WebInfConfiguration
All Implemented Interfaces:
Configuration

public class WebInfConfiguration
extends AbstractConfiguration


Field Summary
protected  Resource _preUnpackBaseResource
           
static String CONTAINER_JAR_PATTERN
           
static String RESOURCE_URLS
          If set, to a list of URLs, these resources are added to the context resource base as a resource collection.
static String TEMPDIR_CONFIGURED
           
static String WEBINF_JAR_PATTERN
           
 
Constructor Summary
WebInfConfiguration()
           
 
Method Summary
 void cloneConfigure(WebAppContext template, WebAppContext context)
          Clone configuration instance.
 void configure(WebAppContext context)
          Configure WebApp.
 void deconfigure(WebAppContext context)
          DeConfigure WebApp.
protected  List<Resource> findJars(WebAppContext context)
          Look for jars in WEB-INF/lib
 File findWorkDirectory(WebAppContext context)
           
static String getCanonicalNameForWebAppTmpDir(WebAppContext context)
          Create a canonical name for a webapp temp directory.
 boolean isTempWorkDirectory(File tmpDir)
          Check if the tmpDir itself is called "work", or if the tmpDir is in a directory called "work".
 void makeTempDirectory(File parent, WebAppContext context, boolean deleteExisting)
           
 void preConfigure(WebAppContext context)
          Set up for configuration.
 void resolveTempDirectory(WebAppContext context)
          Get a temporary directory in which to unpack the war etc etc.
 void unpack(WebAppContext context)
           
 
Methods inherited from class org.eclipse.jetty.webapp.AbstractConfiguration
destroy, postConfigure
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TEMPDIR_CONFIGURED

public static final String TEMPDIR_CONFIGURED
See Also:
Constant Field Values

CONTAINER_JAR_PATTERN

public static final String CONTAINER_JAR_PATTERN
See Also:
Constant Field Values

WEBINF_JAR_PATTERN

public static final String WEBINF_JAR_PATTERN
See Also:
Constant Field Values

RESOURCE_URLS

public static final String RESOURCE_URLS
If set, to a list of URLs, these resources are added to the context resource base as a resource collection.

See Also:
Constant Field Values

_preUnpackBaseResource

protected Resource _preUnpackBaseResource
Constructor Detail

WebInfConfiguration

public WebInfConfiguration()
Method Detail

preConfigure

public void preConfigure(WebAppContext context)
                  throws Exception
Description copied from interface: Configuration
Set up for configuration.

Typically this step discovers configuration resources

Specified by:
preConfigure in interface Configuration
Overrides:
preConfigure in class AbstractConfiguration
Parameters:
context - The context to configure
Throws:
Exception

configure

public void configure(WebAppContext context)
               throws Exception
Description copied from interface: Configuration
Configure WebApp.

Typically this step applies the discovered configuration resources to either the WebAppContext or the associated MetaData.

Specified by:
configure in interface Configuration
Overrides:
configure in class AbstractConfiguration
Parameters:
context - The context to configure
Throws:
Exception

deconfigure

public void deconfigure(WebAppContext context)
                 throws Exception
Description copied from interface: Configuration
DeConfigure WebApp. This method is called to undo all configuration done. This is called to allow the context to work correctly over a stop/start cycle

Specified by:
deconfigure in interface Configuration
Overrides:
deconfigure in class AbstractConfiguration
Parameters:
context - The context to configure
Throws:
Exception

cloneConfigure

public void cloneConfigure(WebAppContext template,
                           WebAppContext context)
                    throws Exception
Description copied from interface: Configuration
Clone configuration instance.

Configure an instance of a WebAppContext, based on a template WebAppContext that has previously been configured by this Configuration.

Specified by:
cloneConfigure in interface Configuration
Overrides:
cloneConfigure in class AbstractConfiguration
Parameters:
template - The template context
context - The context to configure
Throws:
Exception
See Also:
AbstractConfiguration.cloneConfigure(org.eclipse.jetty.webapp.WebAppContext, org.eclipse.jetty.webapp.WebAppContext)

resolveTempDirectory

public void resolveTempDirectory(WebAppContext context)
Get a temporary directory in which to unpack the war etc etc. The algorithm for determining this is to check these alternatives in the order shown:

A. Try to use an explicit directory specifically for this webapp:

  1. Iff an explicit directory is set for this webapp, use it. Do NOT set delete on exit.
  2. Iff javax.servlet.context.tempdir context attribute is set for this webapp && exists && writeable, then use it. Do NOT set delete on exit.

B. Create a directory based on global settings. The new directory will be called "Jetty_"+host+"_"+port+"__"+context+"_"+virtualhost Work out where to create this directory:

  1. Iff $(jetty.home)/work exists create the directory there. Do NOT set delete on exit. Do NOT delete contents if dir already exists.
  2. Iff WEB-INF/work exists create the directory there. Do NOT set delete on exit. Do NOT delete contents if dir already exists.
  3. Else create dir in $(java.io.tmpdir). Set delete on exit. Delete contents if dir already exists.


makeTempDirectory

public void makeTempDirectory(File parent,
                              WebAppContext context,
                              boolean deleteExisting)
                       throws IOException
Throws:
IOException

unpack

public void unpack(WebAppContext context)
            throws IOException
Throws:
IOException

findWorkDirectory

public File findWorkDirectory(WebAppContext context)
                       throws IOException
Throws:
IOException

isTempWorkDirectory

public boolean isTempWorkDirectory(File tmpDir)
Check if the tmpDir itself is called "work", or if the tmpDir is in a directory called "work".

Returns:
true if File is a temporary or work directory

getCanonicalNameForWebAppTmpDir

public static String getCanonicalNameForWebAppTmpDir(WebAppContext context)
Create a canonical name for a webapp temp directory. The form of the name is: "Jetty_"+host+"_"+port+"__"+resourceBase+"_"+context+"_"+virtualhost+base36_hashcode_of_whole_string host and port uniquely identify the server context and virtual host uniquely identify the webapp

Returns:
the canonical name for the webapp temp directory

findJars

protected List<Resource> findJars(WebAppContext context)
                           throws Exception
Look for jars in WEB-INF/lib

Parameters:
context -
Returns:
the list of jar resources found within context
Throws:
Exception


Copyright © 1995-2011 Mort Bay Consulting. All Rights Reserved.