|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mortbay.component.AbstractLifeCycle org.mortbay.jetty.handler.AbstractHandler org.mortbay.jetty.handler.AbstractHandlerContainer org.mortbay.jetty.handler.HandlerWrapper org.mortbay.jetty.handler.ContextHandler org.mortbay.jetty.servlet.Context org.mortbay.jetty.webapp.WebAppContext
public class WebAppContext
Web Application Context Handler.
The WebAppContext handler is an extension of ContextHandler that
coordinates the construction and configuration of nested handlers:
SecurityHandler
, SessionHandler
and ServletHandler
.
The handlers are configured by pluggable configuration classes, with
the default being WebXmlConfiguration
and
JettyWebXmlConfiguration
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.mortbay.jetty.servlet.Context |
---|
Context.SContext |
Field Summary | |
---|---|
static String |
ERROR_PAGE
|
static String |
WEB_DEFAULTS_XML
|
Fields inherited from class org.mortbay.jetty.servlet.Context |
---|
_securityHandler, _servletHandler, _sessionHandler, NO_SECURITY, NO_SESSIONS, SECURITY, SESSIONS |
Fields inherited from class org.mortbay.jetty.handler.ContextHandler |
---|
_scontext |
Fields inherited from class org.mortbay.jetty.handler.AbstractHandler |
---|
_string |
Fields inherited from interface org.mortbay.jetty.Handler |
---|
ALL, DEFAULT, ERROR, FORWARD, INCLUDE, REQUEST |
Constructor Summary | |
---|---|
WebAppContext()
|
|
WebAppContext(HandlerContainer parent,
String webApp,
String contextPath)
|
|
WebAppContext(SecurityHandler securityHandler,
SessionHandler sessionHandler,
ServletHandler servletHandler,
ErrorHandler errorHandler)
|
|
WebAppContext(String webApp,
String contextPath)
|
Method Summary | |
---|---|
void |
addEventListener(EventListener listener)
Add EventListener Conveniance method that calls setEventListeners(EventListener[]) |
static void |
addWebApplications(HandlerContainer contexts,
String webapps,
String defaults,
boolean extract,
boolean java2CompliantClassLoader)
Deprecated. use WebAppDeployer or ContextDeployer |
static void |
addWebApplications(HandlerContainer contexts,
String webapps,
String defaults,
String[] configurations,
boolean extract,
boolean java2CompliantClassLoader)
Deprecated. use WebAppDeployer or ContextDeployer |
static void |
addWebApplications(Server server,
String webapps,
String defaults,
boolean extract,
boolean java2CompliantClassLoader)
Deprecated. use WebAppDeployer or ContextDeployer |
static void |
addWebApplications(Server server,
String webapps,
String defaults,
String[] configurations,
boolean extract,
boolean java2CompliantClassLoader)
Deprecated. use WebAppDeployer or ContextDeployer |
protected void |
doStart()
|
protected void |
doStop()
|
String[] |
getConfigurationClasses()
|
Configuration[] |
getConfigurations()
|
static WebAppContext |
getCurrentWebAppContext()
|
String |
getDefaultsDescriptor()
The default descriptor is a web.xml format file that is applied to the context before the standard WEB-INF/web.xml |
String |
getDescriptor()
|
String |
getExtraClasspath()
|
String |
getOverrideDescriptor()
The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml |
PermissionCollection |
getPermissions()
|
Resource |
getResource(String uriInContext)
|
String |
getResourceAlias(String alias)
|
Map |
getResourceAliases()
|
String[] |
getServerClasses()
|
String[] |
getSystemClasses()
|
File |
getTempDirectory()
Get a temporary directory in which to unpack the war etc etc. |
String |
getWar()
|
Resource |
getWebInf()
|
void |
handle(String target,
HttpServletRequest request,
HttpServletResponse response,
int dispatch)
Handle a request. |
boolean |
isCopyWebDir()
|
boolean |
isDistributable()
|
boolean |
isExtractWAR()
|
boolean |
isParentLoaderPriority()
|
protected boolean |
isProtectedTarget(String target)
Check the target. |
boolean |
isTempWorkDirectory()
Check if the _tmpDir itself is called "work", or if the _tmpDir is in a directory called "work". |
protected void |
loadConfigurations()
|
String |
removeResourceAlias(String alias)
|
protected void |
resolveWebApp()
Resolve Web App directory If the BaseResource has not been set, use the war resource to derive a webapp resource (expanding WAR if required). |
void |
setConfigurationClasses(String[] configurations)
|
void |
setConfigurations(Configuration[] configurations)
|
void |
setCopyWebDir(boolean copy)
|
void |
setDefaultsDescriptor(String defaultsDescriptor)
The default descriptor is a web.xml format file that is applied to the context before the standard WEB-INF/web.xml |
void |
setDescriptor(String descriptor)
|
void |
setDistributable(boolean distributable)
|
void |
setEventListeners(EventListener[] eventListeners)
|
void |
setExtraClasspath(String extraClasspath)
|
void |
setExtractWAR(boolean extractWAR)
|
void |
setOverrideDescriptor(String overrideDescriptor)
The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml |
void |
setParentLoaderPriority(boolean java2compliant)
|
void |
setPermissions(PermissionCollection permissions)
|
void |
setResourceAlias(String alias,
String uri)
Set Resource Alias. |
void |
setResourceAliases(Map map)
|
void |
setSecurityHandler(SecurityHandler securityHandler)
|
void |
setServerClasses(String[] serverClasses)
|
void |
setServletHandler(ServletHandler servletHandler)
|
void |
setSessionHandler(SessionHandler sessionHandler)
|
void |
setSystemClasses(String[] systemClasses)
|
void |
setTempDirectory(File dir)
Set temporary directory for context. |
void |
setWar(String war)
|
protected void |
startContext()
|
String |
toString()
|
Methods inherited from class org.mortbay.jetty.servlet.Context |
---|
addFilter, addFilter, addFilter, addServlet, addServlet, addServlet, getSecurityHandler, getServletHandler, getSessionHandler |
Methods inherited from class org.mortbay.jetty.handler.HandlerWrapper |
---|
addHandler, expandChildren, getHandler, setHandler |
Methods inherited from class org.mortbay.jetty.handler.AbstractHandlerContainer |
---|
expandHandler, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass |
Methods inherited from class org.mortbay.jetty.handler.AbstractHandler |
---|
destroy, getServer |
Methods inherited from class org.mortbay.component.AbstractLifeCycle |
---|
isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, start, stop |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.mortbay.component.LifeCycle |
---|
isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, start, stop |
Field Detail |
---|
public static final String WEB_DEFAULTS_XML
public static final String ERROR_PAGE
Constructor Detail |
---|
public WebAppContext()
public WebAppContext(String webApp, String contextPath)
contextPath
- The context pathwebApp
- The URL or filename of the webapp directory or war file.public WebAppContext(HandlerContainer parent, String webApp, String contextPath)
parent
- The parent HandlerContainer.contextPath
- The context pathwebApp
- The URL or filename of the webapp directory or war file.public WebAppContext(SecurityHandler securityHandler, SessionHandler sessionHandler, ServletHandler servletHandler, ErrorHandler errorHandler)
Method Detail |
---|
public static WebAppContext getCurrentWebAppContext()
public static void addWebApplications(Server server, String webapps, String defaults, boolean extract, boolean java2CompliantClassLoader) throws IOException
WebAppDeployer
or ContextDeployer
server
- Must not be null
webapps
- Directory file name or URL to look for auto
webapplication.defaults
- The defaults xml filename or URL which is
loaded before any in the web app. Must respect the web.dtd.
If null the default defaults file is used. If the empty string, then
no defaults file is used.extract
- If true, extract war filesjava2CompliantClassLoader
- True if java2 compliance is applied to all webapplications
IOException
public static void addWebApplications(Server server, String webapps, String defaults, String[] configurations, boolean extract, boolean java2CompliantClassLoader) throws IOException
WebAppDeployer
or ContextDeployer
server
- Must not be null
.webapps
- Directory file name or URL to look for auto
webapplication.defaults
- The defaults xml filename or URL which is
loaded before any in the web app. Must respect the web.dtd.
If null the default defaults file is used. If the empty string, then
no defaults file is used.configurations
- Array of classnames of Configuration
implementations to apply.extract
- If true, extract war filesjava2CompliantClassLoader
- True if java2 compliance is applied to all webapplications
IOException
IllegalAccessException
InstantiationException
public static void addWebApplications(HandlerContainer contexts, String webapps, String defaults, boolean extract, boolean java2CompliantClassLoader) throws IOException
WebAppDeployer
or ContextDeployer
contexts
- A HandlerContainer to which the contexts will be addedwebapps
- Directory file name or URL to look for auto
webapplication.defaults
- The defaults xml filename or URL which is
loaded before any in the web app. Must respect the web.dtd.
If null the default defaults file is used. If the empty string, then
no defaults file is used.configurations
- Array of classnames of Configuration
implementations to apply.extract
- If true, extract war filesjava2CompliantClassLoader
- True if java2 compliance is applied to all webapplications
IOException
IllegalAccessException
InstantiationException
public static void addWebApplications(HandlerContainer contexts, String webapps, String defaults, String[] configurations, boolean extract, boolean java2CompliantClassLoader) throws IOException
WebAppDeployer
or ContextDeployer
contexts
- A HandlerContainer to which the contexts will be addedwebapps
- Directory file name or URL to look for auto
webapplication.defaults
- The defaults xml filename or URL which is
loaded before any in the web app. Must respect the web.dtd.
If null the default defaults file is used. If the empty string, then
no defaults file is used.configurations
- Array of classnames of Configuration
implementations to apply.extract
- If true, extract war filesjava2CompliantClassLoader
- True if java2 compliance is applied to all webapplications
IOException
IllegalAccessException
InstantiationException
public void setResourceAlias(String alias, String uri)
alias
- uri
- public Map getResourceAliases()
public void setResourceAliases(Map map)
public String getResourceAlias(String alias)
public String removeResourceAlias(String alias)
public Resource getResource(String uriInContext) throws MalformedURLException
getResource
in class ContextHandler
MalformedURLException
public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException
Handler
handle
in interface Handler
handle
in class ContextHandler
target
- The target of the request - either a URI or a name.request
- The request either as the Request
object or a wrapper of that request. The HttpConnection.getCurrentConnection()
method can be used access the Request object if required.response
- The response as the Response
object or a wrapper of that request. The HttpConnection.getCurrentConnection()
method can be used access the Response object if required.dispatch
- The dispatch mode: Handler.REQUEST
, Handler.FORWARD
, Handler.INCLUDE
, Handler.ERROR
IOException
ServletException
ContextHandler.handle(java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, int)
protected void doStart() throws Exception
doStart
in class ContextHandler
Exception
protected void doStop() throws Exception
doStop
in class ContextHandler
Exception
public String[] getConfigurationClasses()
public Configuration[] getConfigurations()
public String getDefaultsDescriptor()
public String getOverrideDescriptor()
public PermissionCollection getPermissions()
public String[] getServerClasses()
public String[] getSystemClasses()
public File getTempDirectory()
A. Try to use an explicit directory specifically for this webapp:
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:
public boolean isTempWorkDirectory()
public String getWar()
public Resource getWebInf() throws IOException
IOException
public boolean isDistributable()
public boolean isExtractWAR()
public boolean isCopyWebDir()
public boolean isParentLoaderPriority()
protected void loadConfigurations() throws Exception
Exception
protected boolean isProtectedTarget(String target)
ContextHandler
ContextHandler.handle(String, HttpServletRequest, HttpServletResponse, int)
when a
target within a context is determined. If the target is protected, 404 is returned.
The default implementation always returns false.
isProtectedTarget
in class ContextHandler
isProtectedTarget(String)
public String toString()
toString
in class ContextHandler
protected void resolveWebApp() throws IOException
IOException
public void setConfigurationClasses(String[] configurations)
configurations
- The configuration class names. If setConfigurations is not called
these classes are used to create a configurations array.public void setConfigurations(Configuration[] configurations)
configurations
- The configurations to set.public void setDefaultsDescriptor(String defaultsDescriptor)
defaultsDescriptor
- The defaultsDescriptor to set.public void setOverrideDescriptor(String overrideDescriptor)
defaultsDescriptor
- The overrideDescritpor to set.public String getDescriptor()
public void setDescriptor(String descriptor)
descriptor
- the web.xml descriptor to use. If set to null, WEB-INF/web.xml is used if it exists.public void setDistributable(boolean distributable)
distributable
- The distributable to set.public void setEventListeners(EventListener[] eventListeners)
setEventListeners
in class ContextHandler
public void addEventListener(EventListener listener)
setEventListeners(EventListener[])
addEventListener
in class ContextHandler
listener
- public void setExtractWAR(boolean extractWAR)
extractWAR
- True if war files are extractedpublic void setCopyWebDir(boolean copy)
copy
- True if the webdir is copied (to allow hot replacement of jars)public void setParentLoaderPriority(boolean java2compliant)
java2compliant
- The java2compliant to set.public void setPermissions(PermissionCollection permissions)
permissions
- The permissions to set.public void setSecurityHandler(SecurityHandler securityHandler)
securityHandler
- The SecurityHandler
to set on this context.public void setServerClasses(String[] serverClasses)
serverClasses
- The serverClasses to set.public void setServletHandler(ServletHandler servletHandler)
servletHandler
- The servletHandler to set.public void setSessionHandler(SessionHandler sessionHandler)
sessionHandler
- The sessionHandler to set.public void setSystemClasses(String[] systemClasses)
systemClasses
- The systemClasses to set.public void setTempDirectory(File dir)
dir
- Writable temporary directory.public void setWar(String war)
war
- The war to set as a file name or URLpublic String getExtraClasspath()
public void setExtraClasspath(String extraClasspath)
extraClasspath
- Comma or semicolon separated path of filenames or URLs
pointing to directories or jar files. Directories should end
with '/'.protected void startContext() throws Exception
startContext
in class Context
Exception
ContextHandler.startContext()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |