org.mortbay.jetty.servlet
Class WebApplicationContext

java.lang.Object
  extended byorg.mortbay.util.Container
      extended byorg.mortbay.http.HttpContext
          extended byorg.mortbay.jetty.servlet.ServletHttpContext
              extended byorg.mortbay.jetty.servlet.WebApplicationContext
All Implemented Interfaces:
EventProvider, java.io.Externalizable, HttpHandler, 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.136 2005/10/26 08:11:04 gregwilkins Exp $
Author:
Greg Wilkins (gregw)
See Also:
WebApplicationHandler, Serialized Form

Nested Class Summary
static interface WebApplicationContext.Configuration
          Base Class for WebApplicationContext Configuration.
 
Field Summary
 
Fields inherited from class org.mortbay.http.HttpContext
__ErrorHandler, __fileClassPathAttr
 
Constructor Summary
WebApplicationContext()
          Constructor.
WebApplicationContext(java.lang.String webApp)
          Constructor.
 
Method Summary
 void addEventListener(java.util.EventListener listener)
          Register an EventListener
 void destroy()
          Destroy a context.
 java.lang.String[] getConfigurationClassNames()
           
 WebApplicationContext.Configuration[] getConfigurations()
           
 java.lang.String getDefaultsDescriptor()
           
 java.lang.String getDisplayName()
           
 java.lang.String getErrorPage(java.lang.String error)
          get error page URI.
 boolean getExtractWAR()
           
 Resource getResource(java.lang.String uriInContext)
           
 java.lang.String getResourceAlias(java.lang.String alias)
           
 java.util.Map getResourceAliases()
           
 ServletHandler getServletHandler()
          Get the context ServletHandler.
 java.lang.String getWAR()
           
 WebApplicationHandler getWebApplicationHandler()
           
 Resource getWebInf()
           
 void handle(java.lang.String pathInContext, java.lang.String pathParams, HttpRequest httpRequest, HttpResponse httpResponse)
          Handler request.
 boolean isDistributable()
           
 boolean isIgnoreWebJetty()
           
 void readExternal(java.io.ObjectInput in)
           
 java.lang.String removeErrorPage(java.lang.String error)
           
 void removeEventListener(java.util.EventListener listener)
           
 java.lang.String removeResourceAlias(java.lang.String alias)
           
 void setConfigurationClassNames(java.lang.String[] configurationClassNames)
           
 void setDefaultsDescriptor(java.lang.String defaults)
          Set the defaults web.xml file.
 void setDisplayName(java.lang.String name)
           
 void setDistributable(boolean distributable)
           
 void setErrorPage(java.lang.String error, java.lang.String uriInContext)
          set error page URI.
 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 setWAR(java.lang.String war)
           
 java.lang.String toString()
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class org.mortbay.jetty.servlet.ServletHttpContext
addLocaleEncoding, addServlet, addServlet, checkSecurityConstraints, enterContextScope, getLocaleEncoding, getServletContext, sendError
 
Methods inherited from class org.mortbay.http.HttpContext
addClassPath, addClassPaths, addHandler, addHandler, addPermission, addSecurityConstraint, addVirtualHost, addWelcomeFile, canonicalContextPathSpec, clearSecurityConstraints, flushCache, getAttribute, getAttributeNames, getAttributes, getAuthenticator, getBaseResource, getClassLoader, getClassPath, getContextPath, getEncodingByMimeType, getEncodingMap, getFileClassPath, getHandler, getHandlerIndex, getHandlers, getHosts, getHttpConnection, getHttpContext, getHttpContextName, getHttpServer, getInitParameter, getInitParameterNames, getMaxCachedFileSize, getMaxCacheSize, getMimeByExtension, getMimeMap, getName, getParentClassLoader, getPermissions, getRealm, getRealmName, getRequestLog, getRequests, getRequestsActive, getRequestsActiveMax, getResourceBase, getResourceMetaData, getResponses1xx, getResponses2xx, getResponses3xx, getResponses4xx, getResponses5xx, getServerClasses, getStatsOn, getStatsOnMs, getStopGracefully, getSystemClasses, getTempDirectory, getVirtualHosts, getWelcomeFile, getWelcomeFiles, handle, initialize, isClassLoaderJava2Compliant, isRedirectNullPath, leaveContextScope, loadClass, log, removeAttribute, removeHandler, removeHandler, removeVirtualHost, removeWelcomeFile, sendContextError, setAttribute, setAttributes, setAuthenticator, setBaseResource, setClassLoader, setClassLoaderJava2Compliant, setClassPath, setContextPath, setEncodingMap, setHandlers, setHosts, setHttpContextName, setInitParameter, setMaxCachedFileSize, setMaxCacheSize, setMimeMap, setMimeMapping, setParentClassLoader, setRealm, setRealmName, setRedirectNullPath, setRequestLog, setResourceBase, setServerClasses, setStatsOn, setStopGracefully, setSystemClasses, setTempDirectory, setTypeEncoding, setVirtualHosts, setWelcomeFiles, statsReset, stop, toString
 
Methods inherited from class org.mortbay.util.Container
getComponents, isStarted, start, stop
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mortbay.util.LifeCycle
isStarted, start, stop
 

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
Throws:
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
Throws:
java.io.IOException
java.lang.ClassNotFoundException

setConfigurationClassNames

public void setConfigurationClassNames(java.lang.String[] configurationClassNames)

getConfigurationClassNames

public java.lang.String[] getConfigurationClassNames()

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()

getWebInf

public Resource getWebInf()
                   throws java.io.IOException
Throws:
java.io.IOException

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.

isDistributable

public boolean isDistributable()

setDistributable

public void setDistributable(boolean distributable)

getConfigurations

public WebApplicationContext.Configuration[] getConfigurations()

destroy

public void destroy()
Description copied from class: HttpContext
Destroy a context. Destroy a context and remove it from the HttpServer. The HttpContext must be stopped before it can be destroyed.

Overrides:
destroy in class ServletHttpContext

handle

public void 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.

Specified by:
handle in interface HttpHandler
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
Description copied from interface: EventProvider
Register an EventListener

Specified by:
addEventListener in interface EventProvider
Overrides:
addEventListener in class Container
Parameters:
listener - ComponentEventListener or LifeCycleEventListener
Throws:
java.lang.IllegalArgumentException

removeEventListener

public void removeEventListener(java.util.EventListener listener)
Specified by:
removeEventListener in interface EventProvider
Overrides:
removeEventListener in class Container

getDisplayName

public java.lang.String getDisplayName()

setDisplayName

public void setDisplayName(java.lang.String name)

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

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 -

getResourceAliases

public java.util.Map getResourceAliases()

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
Overrides:
getResource in class HttpContext
Parameters:
uriInContext -
Returns:
Throws:
java.io.IOException

setErrorPage

public void setErrorPage(java.lang.String error,
                         java.lang.String uriInContext)
set error page URI.

Parameters:
error - A string representing an error code or a exception classname
uriInContext -

getErrorPage

public java.lang.String getErrorPage(java.lang.String error)
get error page URI.

Parameters:
error - A string representing an error code or a exception classname
Returns:
URI within context

removeErrorPage

public java.lang.String removeErrorPage(java.lang.String error)


Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.