org.mortbay.jetty.servlet

Class WebApplicationContext

public class WebApplicationContext extends ServletHttpContext implements 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

Nested Class Summary
static interfaceWebApplicationContext.Configuration
Base Class for WebApplicationContext Configuration.
Constructor Summary
WebApplicationContext()
Constructor.
WebApplicationContext(String webApp)
Constructor.
Method Summary
voidaddEventListener(EventListener listener)
protected voidconfigureClassPath()
protected voidconfigureDefaults()
protected voidconfigureWebApp()
voiddestroy()
protected voiddoStart()
Start the Web Application.
protected voiddoStop()
Stop the web application.
String[]getConfigurationClassNames()
WebApplicationContext.Configuration[]getConfigurations()
StringgetDefaultsDescriptor()
StringgetDisplayName()
StringgetErrorPage(String error)
get error page URI.
booleangetExtractWAR()
ResourcegetResource(String uriInContext)
StringgetResourceAlias(String alias)
MapgetResourceAliases()
ServletHandlergetServletHandler()
Get the context ServletHandler.
protected UserRealmgetUserRealm(String name)
StringgetWAR()
WebApplicationHandlergetWebApplicationHandler()
ResourcegetWebInf()
voidhandle(String pathInContext, String pathParams, HttpRequest httpRequest, HttpResponse httpResponse)
protected voidinitialize()
Initialize is called by the start method after the contexts classloader has been initialied, but before the defaults descriptor has been applied.
booleanisDistributable()
booleanisIgnoreWebJetty()
protected WebApplicationContext.Configuration[]loadConfigurations()
voidreadExternal(ObjectInput in)
StringremoveErrorPage(String error)
voidremoveEventListener(EventListener listener)
StringremoveResourceAlias(String alias)
voidsetConfigurationClassNames(String[] configurationClassNames)
voidsetDefaultsDescriptor(String defaults)
Set the defaults web.xml file.
voidsetDisplayName(String name)
voidsetDistributable(boolean distributable)
voidsetErrorPage(String error, String uriInContext)
set error page URI.
voidsetExtractWAR(boolean extract)
voidsetIgnoreWebJetty(boolean b)
voidsetPermissions(PermissionCollection permissions)
voidsetResourceAlias(String alias, String uri)
Set Resource Alias.
voidsetWAR(String war)
StringtoString()
voidwriteExternal(ObjectOutput out)

Constructor Detail

WebApplicationContext

public WebApplicationContext()
Constructor.

WebApplicationContext

public WebApplicationContext(String webApp)
Constructor.

Parameters: webApp The Web application directory or WAR file.

Method Detail

addEventListener

public void addEventListener(EventListener listener)

configureClassPath

protected void configureClassPath()

configureDefaults

protected void configureDefaults()

configureWebApp

protected void configureWebApp()

destroy

public void destroy()

doStart

protected void doStart()
Start the Web Application.

Throws: IOException

doStop

protected void doStop()
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().

Throws: InterruptedException

getConfigurationClassNames

public String[] getConfigurationClassNames()

getConfigurations

public WebApplicationContext.Configuration[] getConfigurations()

getDefaultsDescriptor

public String getDefaultsDescriptor()

getDisplayName

public String getDisplayName()

getErrorPage

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

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

Returns: URI within context

getExtractWAR

public boolean getExtractWAR()

getResource

public Resource getResource(String uriInContext)

getResourceAlias

public String getResourceAlias(String alias)

getResourceAliases

public Map getResourceAliases()

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.

Returns: WebApplicationHandler

getUserRealm

protected UserRealm getUserRealm(String name)

getWAR

public String getWAR()

getWebApplicationHandler

public WebApplicationHandler getWebApplicationHandler()

getWebInf

public Resource getWebInf()

handle

public void handle(String pathInContext, String pathParams, HttpRequest httpRequest, HttpResponse httpResponse)

initialize

protected void initialize()
Initialize is called by the start method after the contexts classloader has been initialied, but before the defaults descriptor has been applied. The default implementation does nothing.

Throws: Exception if an error occurs

isDistributable

public boolean isDistributable()

isIgnoreWebJetty

public boolean isIgnoreWebJetty()

loadConfigurations

protected WebApplicationContext.Configuration[] loadConfigurations()

readExternal

public void readExternal(ObjectInput in)

removeErrorPage

public String removeErrorPage(String error)

removeEventListener

public void removeEventListener(EventListener listener)

removeResourceAlias

public String removeResourceAlias(String alias)

setConfigurationClassNames

public void setConfigurationClassNames(String[] configurationClassNames)

setDefaultsDescriptor

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

setDisplayName

public void setDisplayName(String name)

setDistributable

public void setDistributable(boolean distributable)

setErrorPage

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

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

setExtractWAR

public void setExtractWAR(boolean extract)

Parameters: extract If true, a WAR is extracted to a temporary directory before being deployed.

setIgnoreWebJetty

public void setIgnoreWebJetty(boolean b)

Parameters: b If TRUE, web-jetty.xml and jetty-web.xml configuration files are ignored.

setPermissions

public void setPermissions(PermissionCollection permissions)

setResourceAlias

public void setResourceAlias(String alias, 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

setWAR

public void setWAR(String war)

Parameters: war Filename or URL of the web application directory or WAR file.

toString

public String toString()

writeExternal

public void writeExternal(ObjectOutput out)
Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.