public class ContextHandler extends HandlerWrapper implements org.mortbay.util.Attributes, Server.Graceful
If the context init parameter "org.mortbay.jetty.servlet.ManagedAttributes" is set to a coma separated list of names, then they are treated as context attribute names, which if set as attributes are passed to the servers Container so that they may be managed with JMX.
Modifier and Type | Class and Description |
---|---|
class |
ContextHandler.SContext
Context.
|
Modifier and Type | Field and Description |
---|---|
protected ContextHandler.SContext |
_scontext |
static java.lang.String |
MANAGED_ATTRIBUTES |
_string
Modifier | Constructor and Description |
---|---|
|
ContextHandler() |
protected |
ContextHandler(ContextHandler.SContext context) |
|
ContextHandler(HandlerContainer parent,
java.lang.String contextPath) |
|
ContextHandler(java.lang.String contextPath) |
Modifier and Type | Method and Description |
---|---|
void |
addEventListener(java.util.EventListener listener) |
void |
addLocaleEncoding(java.lang.String locale,
java.lang.String encoding) |
void |
clearAttributes() |
protected void |
doStart() |
protected void |
doStop() |
boolean |
getAllowNullPathInfo() |
java.lang.Object |
getAttribute(java.lang.String name) |
java.util.Enumeration |
getAttributeNames() |
org.mortbay.util.Attributes |
getAttributes() |
Resource |
getBaseResource() |
java.lang.ClassLoader |
getClassLoader() |
java.lang.String |
getClassPath()
Make best effort to extract a file classpath from the context classloader
|
java.lang.String[] |
getConnectorNames() |
java.lang.String |
getContextPath() |
static ContextHandler.SContext |
getCurrentContext()
Get the current ServletContext implementation.
|
java.lang.String |
getDisplayName() |
ErrorHandler |
getErrorHandler() |
java.util.EventListener[] |
getEventListeners() |
java.lang.String[] |
getHosts()
Deprecated.
|
java.lang.String |
getInitParameter(java.lang.String name) |
java.util.Enumeration |
getInitParameterNames() |
java.util.Map |
getInitParams() |
java.lang.String |
getLocaleEncoding(java.util.Locale locale)
Get the character encoding for a locale.
|
int |
getMaxFormContentSize() |
int |
getMaxFormKeys() |
MimeTypes |
getMimeTypes() |
Resource |
getResource(java.lang.String path) |
java.lang.String |
getResourceBase() |
java.util.Set |
getResourcePaths(java.lang.String path) |
ContextHandler.SContext |
getServletContext() |
java.lang.String[] |
getVirtualHosts()
Get the virtual hosts for the context.
|
java.lang.String[] |
getWelcomeFiles() |
void |
handle(java.lang.String target,
HttpServletRequest request,
HttpServletResponse response,
int dispatch)
Handle a request.
|
boolean |
isCompactPath() |
protected boolean |
isProtectedTarget(java.lang.String target)
Check the target.
|
boolean |
isShutdown() |
java.lang.Class |
loadClass(java.lang.String className) |
void |
removeAttribute(java.lang.String name) |
void |
setAllowNullPathInfo(boolean allowNullPathInfo) |
void |
setAttribute(java.lang.String name,
java.lang.Object value) |
void |
setAttributes(org.mortbay.util.Attributes attributes) |
void |
setBaseResource(Resource base) |
void |
setClassLoader(java.lang.ClassLoader classLoader) |
void |
setCompactPath(boolean compactPath) |
void |
setConnectorNames(java.lang.String[] connectors)
Set the names of accepted connectors.
|
void |
setContextPath(java.lang.String contextPath) |
void |
setDisplayName(java.lang.String servletContextName) |
void |
setErrorHandler(ErrorHandler errorHandler) |
void |
setEventListeners(java.util.EventListener[] eventListeners) |
void |
setHosts(java.lang.String[] hosts)
Deprecated.
|
void |
setInitParams(java.util.Map initParams) |
void |
setMaxFormContentSize(int maxSize)
Set the maximum size of a form post, to protect against DOS attacks from large forms.
|
void |
setMaxFormKeys(int max)
Set the maximum number of form Keys to protect against DOS attack from crafted hash keys.
|
void |
setMimeTypes(MimeTypes mimeTypes) |
void |
setResourceBase(java.lang.String resourceBase) |
void |
setServer(Server server) |
void |
setShutdown(boolean shutdown)
Set shutdown status.
|
void |
setVirtualHosts(java.lang.String[] vhosts)
Set the virtual hosts for the context.
|
void |
setWelcomeFiles(java.lang.String[] files) |
protected void |
startContext() |
java.lang.String |
toString() |
addHandler, expandChildren, getHandler, removeHandler, setHandler
expandHandler, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass
destroy, getServer
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
public static final java.lang.String MANAGED_ATTRIBUTES
protected ContextHandler.SContext _scontext
public ContextHandler()
protected ContextHandler(ContextHandler.SContext context)
public ContextHandler(java.lang.String contextPath)
public ContextHandler(HandlerContainer parent, java.lang.String contextPath)
public static ContextHandler.SContext getCurrentContext()
public ContextHandler.SContext getServletContext()
public boolean getAllowNullPathInfo()
public void setAllowNullPathInfo(boolean allowNullPathInfo)
allowNullPathInfo
- true if /context is not redirected to /context/public void setServer(Server server)
setServer
in interface Handler
setServer
in class HandlerWrapper
public void setVirtualHosts(java.lang.String[] vhosts)
vhosts
- Array of virtual hosts that this context responds to. A
null host name or null/empty array means any hostname is acceptable.
Host names may be String representation of IP addresses. Host names may
start with '*.' to wildcard one level of names.public java.lang.String[] getVirtualHosts()
public void setHosts(java.lang.String[] hosts)
setConnectorNames(String[])
public java.lang.String[] getHosts()
public java.lang.String[] getConnectorNames()
public void setConnectorNames(java.lang.String[] connectors)
connectors
- If non null, an array of connector names that this context
will accept a request from.public java.lang.Object getAttribute(java.lang.String name)
getAttribute
in interface org.mortbay.util.Attributes
public java.util.Enumeration getAttributeNames()
getAttributeNames
in interface org.mortbay.util.Attributes
public org.mortbay.util.Attributes getAttributes()
public java.lang.ClassLoader getClassLoader()
public java.lang.String getClassPath()
public java.lang.String getContextPath()
public java.lang.String getInitParameter(java.lang.String name)
public java.util.Enumeration getInitParameterNames()
public java.util.Map getInitParams()
public java.lang.String getDisplayName()
public java.util.EventListener[] getEventListeners()
public void setEventListeners(java.util.EventListener[] eventListeners)
public void addEventListener(java.util.EventListener listener)
public boolean isShutdown()
public void setShutdown(boolean shutdown)
setShutdown
in interface Server.Graceful
accepting
- true if this context is accepting new requestsprotected void doStart() throws java.lang.Exception
doStart
in class HandlerWrapper
java.lang.Exception
protected void startContext() throws java.lang.Exception
java.lang.Exception
protected void doStop() throws java.lang.Exception
doStop
in class HandlerWrapper
java.lang.Exception
public void handle(java.lang.String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws java.io.IOException, ServletException
Handler
handle
in interface Handler
handle
in class HandlerWrapper
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
java.io.IOException
ServletException
protected boolean isProtectedTarget(java.lang.String target)
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.public void removeAttribute(java.lang.String name)
removeAttribute
in interface org.mortbay.util.Attributes
public void setAttribute(java.lang.String name, java.lang.Object value)
setAttribute
in interface org.mortbay.util.Attributes
public void setAttributes(org.mortbay.util.Attributes attributes)
attributes
- The attributes to set.public void clearAttributes()
clearAttributes
in interface org.mortbay.util.Attributes
public void setClassLoader(java.lang.ClassLoader classLoader)
classLoader
- The classLoader to set.public void setContextPath(java.lang.String contextPath)
contextPath
- The _contextPath to set.public void setInitParams(java.util.Map initParams)
initParams
- The initParams to set.public void setDisplayName(java.lang.String servletContextName)
servletContextName
- The servletContextName to set.public Resource getBaseResource()
public java.lang.String getResourceBase()
public void setBaseResource(Resource base)
base
- The resourceBase to set.public void setResourceBase(java.lang.String resourceBase)
resourceBase
- The base resource as a string.public MimeTypes getMimeTypes()
public void setMimeTypes(MimeTypes mimeTypes)
mimeTypes
- The mimeTypes to set.public void setWelcomeFiles(java.lang.String[] files)
public java.lang.String[] getWelcomeFiles()
setWelcomeFiles(java.lang.String[])
public ErrorHandler getErrorHandler()
public void setErrorHandler(ErrorHandler errorHandler)
errorHandler
- The errorHandler to set.public int getMaxFormContentSize()
public void setMaxFormContentSize(int maxSize)
maxSize
- public int getMaxFormKeys()
public void setMaxFormKeys(int max)
max
- public boolean isCompactPath()
public void setCompactPath(boolean compactPath)
compactPath
- True if URLs are compacted to replace multiple '/'s with a single '/'public java.lang.String toString()
toString
in class AbstractHandler
public java.lang.Class loadClass(java.lang.String className) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
public void addLocaleEncoding(java.lang.String locale, java.lang.String encoding)
public java.lang.String getLocaleEncoding(java.util.Locale locale)
locale
- a Locale
valueString
representing the character encoding for
the locale or null if none found.public Resource getResource(java.lang.String path) throws java.net.MalformedURLException
java.net.MalformedURLException
public java.util.Set getResourcePaths(java.lang.String path)
Copyright © 2009 Mortbay Consulting Pty. Ltd. All Rights Reserved.