org.mortbay.jetty.servlet
Class WebApplicationContext

java.lang.Object
  |
  +--org.mortbay.http.HttpContext
        |
        +--org.mortbay.jetty.servlet.ServletHttpContext
              |
              +--org.mortbay.jetty.servlet.WebApplicationContext
All Implemented Interfaces:
java.io.Externalizable, LifeCycle, java.io.Serializable
Direct Known Subclasses:
PlusWebAppContext

public class WebApplicationContext
extends ServletHttpContext
implements java.io.Externalizable

Standard web.xml configured HttpContext. This specialization of HttpContext uses the standardized web.xml to describe a web application and configure the handlers for the HttpContext. If a file named web-jetty.xml or jetty-web.xml is found in the WEB-INF directory it is applied to the context using the XmlConfiguration format. A single WebApplicationHandler instance is used to provide security, filter, sevlet and resource handling.

Version:
$Id: WebApplicationContext.java,v 1.98.2.5 2004/03/29 12:51:43 gregwilkins Exp $
Author:
Greg Wilkins (gregw)
See Also:
WebApplicationHandler, Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.mortbay.http.HttpContext
HttpContext.ResourceMetaData
 
Field Summary
 
Fields inherited from class org.mortbay.http.HttpContext
__fileClassPathAttr
 
Constructor Summary
WebApplicationContext()
          Constructor.
WebApplicationContext(java.lang.String webApp)
          Constructor.
 
Method Summary
 void addEventListener(java.util.EventListener listener)
           
 java.lang.String getDefaultsDescriptor()
           
 java.lang.String getDeploymentDescriptor()
           
 java.lang.String getDisplayName()
           
 boolean getExtractWAR()
           
 Resource getResource(java.lang.String uriInContext)
          Get a resource from the context.
 java.lang.String getResourceAlias(java.lang.String alias)
           
 ServletHandler getServletHandler()
          Get the context ServletHandler.
 java.util.Map getTagLibMap()
          Get the taglib map.
 java.lang.String getWAR()
           
 WebApplicationHandler getWebApplicationHandler()
           
 boolean handle(java.lang.String pathInContext, java.lang.String pathParams, HttpRequest httpRequest, HttpResponse httpResponse)
          Handler request.
 boolean isIgnoreWebJetty()
           
 void readExternal(java.io.ObjectInput in)
           
 void removeAttribute(java.lang.String name)
           
 void removeEventListener(java.util.EventListener listener)
           
 java.lang.String removeResourceAlias(java.lang.String alias)
           
 void setAttribute(java.lang.String name, java.lang.Object value)
          Set a context attribute.
 void setBaseResource(Resource baseResource)
          Set the base resource.
 void setClassPath(java.lang.String classPath)
          Sets the class path for the context.
 void setDefaultsDescriptor(java.lang.String defaults)
          Set the defaults web.xml file.
 void setExtractWAR(boolean extract)
           
 void setIgnoreWebJetty(boolean b)
           
 void setPermissions(java.security.PermissionCollection permissions)
          Set the permissions to be used for this context.
 void setResourceAlias(java.lang.String alias, java.lang.String uri)
          Set Resource Alias.
 void setResourceBase(java.lang.String resourceBase)
          Set the Resource Base.
 void setWAR(java.lang.String war)
           
 void start()
          Start the Web Application.
 void stop()
          Stop the web application.
 java.lang.String toString()
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class org.mortbay.jetty.servlet.ServletHttpContext
addServlet, addServlet, checkSecurityConstraints, getServletContext, setDynamicServletPathSpec
 
Methods inherited from class org.mortbay.http.HttpContext
addHandler, addHandler, addPermission, addSecurityConstraint, addVirtualHost, addWelcomeFile, canonicalContextPathSpec, clearSecurityConstraints, destroy, flushCache, getAttribute, getAttributeNames, getAttributes, getAuthenticator, getBaseResource, getClassLoader, getClassPath, getContextPath, getEncodingByMimeType, getEncodingMap, getErrorPage, getFileClassPath, getHandler, getHandlerIndex, getHandlers, getHosts, getHttpConnection, getHttpContextName, getHttpServer, getInitParameter, getInitParameterNames, getMaxCachedFileSize, getMaxCacheSize, getMimeByExtension, getMimeMap, getParentClassLoader, getPermissions, getRealm, getRealmName, getRequestLog, getRequests, getRequestsActive, getRequestsActiveMax, getResourceBase, getResourceMetaData, getResponses1xx, getResponses2xx, getResponses3xx, getResponses4xx, getResponses5xx, getStatsOn, getStatsOnMs, getTempDirectory, getVirtualHosts, getWelcomeFile, getWelcomeFiles, handle, isAuthConstrained, isClassLoaderJava2Compliant, isRedirectNullPath, isStarted, loadClass, log, removeErrorPage, removeHandler, removeHandler, removeVirtualHost, removeWelcomeFile, setAttributes, setAuthenticator, setClassLoader, setClassLoaderJava2Compliant, setClassPaths, setClassPaths, setContextPath, setEncodingMap, setErrorPage, setHandlers, setHosts, setInitParameter, setMaxCachedFileSize, setMaxCacheSize, setMimeMap, setMimeMapping, setParentClassLoader, setRealm, setRealmName, setRedirectNullPath, setRequestLog, setStatsOn, setTempDirectory, setTypeEncoding, setVirtualHosts, setWelcomeFiles, statsReset, stop, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WebApplicationContext

public WebApplicationContext()
Constructor.


WebApplicationContext

public WebApplicationContext(java.lang.String webApp)
Constructor.

Parameters:
webApp - The Web application directory or WAR file.
Method Detail

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
java.io.IOException
java.lang.ClassNotFoundException

setWAR

public void setWAR(java.lang.String war)
Parameters:
war - Filename or URL of the web application directory or WAR file.

getWAR

public java.lang.String getWAR()

getWebApplicationHandler

public WebApplicationHandler getWebApplicationHandler()

getServletHandler

public ServletHandler getServletHandler()
Get the context ServletHandler. Conveniance method. If no ServletHandler exists, a new one is added to the context. This derivation of the method creates a WebApplicationHandler extension of ServletHandler.

Overrides:
getServletHandler in class ServletHttpContext
Returns:
WebApplicationHandler

setPermissions

public void setPermissions(java.security.PermissionCollection permissions)
Description copied from class: HttpContext
Set the permissions to be used for this context. The collection of permissions set here are used for all classes loaded by this context. This is simpler that creating a security policy file, as not all code sources may be statically known.

Overrides:
setPermissions in class HttpContext
Parameters:
permissions -

isIgnoreWebJetty

public boolean isIgnoreWebJetty()

setIgnoreWebJetty

public void setIgnoreWebJetty(boolean b)
Parameters:
b - If TRUE, web-jetty.xml and jetty-web.xml configuration files are ignored.

start

public void start()
           throws java.lang.Exception
Start the Web Application.

Specified by:
start in interface LifeCycle
Overrides:
start in class HttpContext
Throws:
java.io.IOException
java.lang.Exception - An arbitrary exception may be thrown.

stop

public void stop()
          throws java.lang.InterruptedException
Stop the web application. Handlers for resource, servlet, filter and security are removed as they are recreated and configured by any subsequent call to start().

Specified by:
stop in interface LifeCycle
Overrides:
stop in class ServletHttpContext
Throws:
java.lang.InterruptedException

handle

public boolean handle(java.lang.String pathInContext,
                      java.lang.String pathParams,
                      HttpRequest httpRequest,
                      HttpResponse httpResponse)
               throws HttpException,
                      java.io.IOException
Description copied from class: HttpContext
Handler request. Call each HttpHandler until request is handled.

Overrides:
handle in class HttpContext
Parameters:
pathInContext - Path in context
pathParams - Path parameters such as encoded Session ID
httpRequest -
httpResponse -
Returns:
True if the request has been handled.
Throws:
HttpException
java.io.IOException

addEventListener

public void addEventListener(java.util.EventListener listener)
                      throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException

removeEventListener

public void removeEventListener(java.util.EventListener listener)

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Description copied from class: HttpContext
Set a context attribute. Attributes are cleared when the context is stopped.

Overrides:
setAttribute in class HttpContext
Parameters:
name - attribute name
value - attribute value

removeAttribute

public void removeAttribute(java.lang.String name)
Overrides:
removeAttribute in class HttpContext
Parameters:
name - attribute name

getDisplayName

public java.lang.String getDisplayName()

getDeploymentDescriptor

public java.lang.String getDeploymentDescriptor()

setDefaultsDescriptor

public void setDefaultsDescriptor(java.lang.String defaults)
Set the defaults web.xml file. The default web.xml is used to configure all webapplications before the WEB-INF/web.xml file is applied. By default the org/mortbay/jetty/servlet/webdefault.xml resource from the org.mortbay.jetty.jar is used.

Parameters:
defaults - File, Resource, URL or null.

getDefaultsDescriptor

public java.lang.String getDefaultsDescriptor()

setExtractWAR

public void setExtractWAR(boolean extract)
Parameters:
extract - If true, a WAR is extracted to a temporary directory before being deployed.

getExtractWAR

public boolean getExtractWAR()

toString

public java.lang.String toString()
Overrides:
toString in class ServletHttpContext

setClassPath

public void setClassPath(java.lang.String classPath)
Description copied from class: HttpContext
Sets the class path for the context. A class path is only required for a context if it uses classes that are not in the system class path.

Overrides:
setClassPath in class HttpContext
Parameters:
classPath - a comma or ';' separated list of class resources. These may be jar files, directories or URLs to jars or directories.

setResourceBase

public void setResourceBase(java.lang.String resourceBase)
Description copied from class: HttpContext
Set the Resource Base. The base resource is the Resource to use as a relative base for all context resources. The ResourceBase attribute is a string version of the baseResource. If a relative file is passed, it is converted to a file URL based on the current working directory.

Overrides:
setResourceBase in class HttpContext
Parameters:
resourceBase - A URL prefix or directory name.

setBaseResource

public void setBaseResource(Resource baseResource)
Description copied from class: HttpContext
Set the base resource. The base resource is the Resource to use as a relative base for all context resources. The ResourceBase attribute is a string version of the baseResource.

Overrides:
setBaseResource in class HttpContext
Parameters:
baseResource - The resourceBase as a Resource instance

getTagLibMap

public java.util.Map getTagLibMap()
Get the taglib map.

Returns:
A map of uri to location for tag libraries.

setResourceAlias

public void setResourceAlias(java.lang.String alias,
                             java.lang.String uri)
Set Resource Alias. Resource aliases map resource uri's within a context. They may optionally be used by a handler when looking for a resource.

Parameters:
alias -
uri -

getResourceAlias

public java.lang.String getResourceAlias(java.lang.String alias)

removeResourceAlias

public java.lang.String removeResourceAlias(java.lang.String alias)

getResource

public Resource getResource(java.lang.String uriInContext)
                     throws java.io.IOException
Description copied from class: HttpContext
Get a resource from the context. Cached Resources are returned if the resource fits within the LRU cache. Directories may have CachedResources returned, but the caller must use the CachedResource.setCachedData method to set the formatted directory content.

Overrides:
getResource in class HttpContext
Parameters:
uriInContext -
Returns:
Resource
Throws:
java.io.IOException


Copyright ? 2000 Mortbay Consulting Pty. Ltd. All Rights Reserved.