|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.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:
ConstraintsSecurityHandler
, 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 |
Nested classes/interfaces inherited from interface org.mortbay.component.LifeCycle |
---|
LifeCycle.Listener |
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, MANAGED_ATTRIBUTES |
Fields inherited from class org.mortbay.jetty.handler.AbstractHandler |
---|
_string |
Fields inherited from class org.mortbay.component.AbstractLifeCycle |
---|
_listeners |
Fields inherited from interface org.mortbay.jetty.handler.CompleteHandler |
---|
COMPLETE_HANDLER_ATTR |
Fields inherited from interface org.mortbay.jetty.Handler |
---|
ALL, DEFAULT, ERROR, FORWARD, INCLUDE, REQUEST |
Constructor Summary | |
---|---|
WebAppContext()
|
|
WebAppContext(ConstraintsSecurityHandler securityHandler,
SessionHandler sessionHandler,
ServletHandler servletHandler,
ErrorHandler errorHandler)
|
|
WebAppContext(HandlerContainer parent,
String webApp,
String contextPath)
|
|
WebAppContext(String webApp,
String contextPath)
|
Method Summary | |
---|---|
void |
addEventListener(EventListener listener)
Add EventListener Conveniance method that calls setEventListeners(EventListener[]) |
protected void |
doStart()
|
protected void |
doStop()
|
void |
dumpUrl()
|
String[] |
getConfigurationClasses()
|
Configuration[] |
getConfigurations()
|
ConstraintsSecurityHandler |
getConstraintsSecurityHandler()
|
static ContextHandler |
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. |
Throwable |
getUnavailableException()
Get an exception that caused the webapp to be unavailable |
String |
getWar()
|
Resource |
getWebInf()
|
void |
handle(String target,
HttpServletRequest request,
HttpServletResponse response,
int dispatch)
Handle a request. |
boolean |
isCopyWebDir()
|
boolean |
isDistributable()
|
boolean |
isExtractWAR()
|
boolean |
isLogUrlOnStart()
|
boolean |
isParentLoaderPriority()
|
protected boolean |
isProtectedTarget(String target)
Check the target. |
boolean |
isServerClass(String name)
|
boolean |
isSystemClass(String name)
|
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 |
setClassLoader(ClassLoader classLoader)
|
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 |
setDisplayName(String servletContextName)
|
void |
setDistributable(boolean distributable)
|
void |
setEventListeners(EventListener[] eventListeners)
Set the context event listeners. |
void |
setExtraClasspath(String extraClasspath)
|
void |
setExtractWAR(boolean extractWAR)
|
void |
setLogUrlOnStart(boolean logOnStart)
Sets whether or not the web app name and URL is logged on startup |
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 |
setServerClasses(String[] serverClasses)
Set the server classes patterns. |
void |
setSystemClasses(String[] systemClasses)
Set the system classes patterns. |
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, setSecurityHandler, setServletHandler, setSessionHandler |
Methods inherited from class org.mortbay.jetty.handler.HandlerWrapper |
---|
addHandler, expandChildren, getHandler, removeHandler, 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 |
---|
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, 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 |
---|
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, 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(ConstraintsSecurityHandler securityHandler, SessionHandler sessionHandler, ServletHandler servletHandler, ErrorHandler errorHandler)
Method Detail |
---|
public static ContextHandler getCurrentWebAppContext()
public void setDisplayName(String servletContextName)
setDisplayName
in class ContextHandler
servletContextName
- The servletContextName to set.public Throwable getUnavailableException()
public ConstraintsSecurityHandler getConstraintsSecurityHandler()
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 void setClassLoader(ClassLoader classLoader)
setClassLoader
in class ContextHandler
classLoader
- The classLoader to set.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
public void dumpUrl()
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()
setServerClasses(String[])
public String[] getSystemClasses()
setSystemClasses(String[])
public boolean isServerClass(String name)
public boolean isSystemClass(String name)
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)
ContextHandler
setEventListeners
in class ContextHandler
ServletContextListener
,
ServletContextAttributeListener
,
ServletRequestListener
,
ServletRequestAttributeListener
public void addEventListener(EventListener listener)
setEventListeners(EventListener[])
addEventListener
in class ContextHandler
listener
- ServletContextListener
,
ServletContextAttributeListener
,
ServletRequestListener
,
ServletRequestAttributeListener
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 setServerClasses(String[] serverClasses)
Server classes/packages are classes used to implement the server and are hidden from the context. If the context needs to load these classes, it must have its own copy of them in WEB-INF/lib or WEB-INF/classes. A class pattern is a string of one of the forms:
serverClasses
- The serverClasses to set.public void setSystemClasses(String[] systemClasses)
System classes/packages are classes provided by the JVM and that
cannot be replaced by classes of the same name from WEB-INF,
regardless of the value of setParentLoaderPriority(boolean)
.
A class pattern is a string of one of the forms:
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 '/'.public boolean isLogUrlOnStart()
public void setLogUrlOnStart(boolean logOnStart)
logOnStart
- whether or not the log message is createdprotected 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 |