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 String |
MANAGED_ATTRIBUTES |
_string| Modifier | Constructor and Description |
|---|---|
|
ContextHandler() |
protected |
ContextHandler(ContextHandler.SContext context) |
|
ContextHandler(HandlerContainer parent,
String contextPath) |
|
ContextHandler(String contextPath) |
| Modifier and Type | Method and Description |
|---|---|
void |
addEventListener(EventListener listener) |
void |
addLocaleEncoding(String locale,
String encoding) |
void |
clearAttributes() |
protected void |
doStart() |
protected void |
doStop() |
boolean |
getAllowNullPathInfo() |
Object |
getAttribute(String name) |
Enumeration |
getAttributeNames() |
org.mortbay.util.Attributes |
getAttributes() |
Resource |
getBaseResource() |
ClassLoader |
getClassLoader() |
String |
getClassPath()
Make best effort to extract a file classpath from the context classloader
|
String[] |
getConnectorNames() |
String |
getContextPath() |
static ContextHandler.SContext |
getCurrentContext()
Get the current ServletContext implementation.
|
String |
getDisplayName() |
ErrorHandler |
getErrorHandler() |
EventListener[] |
getEventListeners() |
String[] |
getHosts()
Deprecated.
|
String |
getInitParameter(String name) |
Enumeration |
getInitParameterNames() |
Map |
getInitParams() |
String |
getLocaleEncoding(Locale locale)
Get the character encoding for a locale.
|
int |
getMaxFormContentSize() |
int |
getMaxFormKeys() |
MimeTypes |
getMimeTypes() |
Resource |
getResource(String path) |
String |
getResourceBase() |
Set |
getResourcePaths(String path) |
ContextHandler.SContext |
getServletContext() |
String[] |
getVirtualHosts()
Get the virtual hosts for the context.
|
String[] |
getWelcomeFiles() |
void |
handle(String target,
HttpServletRequest request,
HttpServletResponse response,
int dispatch)
Handle a request.
|
boolean |
isCompactPath() |
protected boolean |
isProtectedTarget(String target)
Check the target.
|
boolean |
isShutdown() |
Class |
loadClass(String className) |
void |
removeAttribute(String name) |
void |
setAllowNullPathInfo(boolean allowNullPathInfo) |
void |
setAttribute(String name,
Object value) |
void |
setAttributes(org.mortbay.util.Attributes attributes) |
void |
setBaseResource(Resource base) |
void |
setClassLoader(ClassLoader classLoader) |
void |
setCompactPath(boolean compactPath) |
void |
setConnectorNames(String[] connectors)
Set the names of accepted connectors.
|
void |
setContextPath(String contextPath) |
void |
setDisplayName(String servletContextName) |
void |
setErrorHandler(ErrorHandler errorHandler) |
void |
setEventListeners(EventListener[] eventListeners) |
void |
setHosts(String[] hosts)
Deprecated.
|
void |
setInitParams(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(String resourceBase) |
void |
setServer(Server server) |
void |
setShutdown(boolean shutdown)
Set shutdown status.
|
void |
setVirtualHosts(String[] vhosts)
Set the virtual hosts for the context.
|
void |
setWelcomeFiles(String[] files) |
protected void |
startContext() |
String |
toString() |
addHandler, expandChildren, getHandler, removeHandler, setHandlerexpandHandler, getChildHandlerByClass, getChildHandlers, getChildHandlersByClassdestroy, getServeraddLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stoppublic static final String MANAGED_ATTRIBUTES
protected ContextHandler.SContext _scontext
public ContextHandler()
protected ContextHandler(ContextHandler.SContext context)
public ContextHandler(String contextPath)
public ContextHandler(HandlerContainer parent, 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 HandlersetServer in class HandlerWrapperpublic void setVirtualHosts(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 String[] getVirtualHosts()
public void setHosts(String[] hosts)
setConnectorNames(String[])public String[] getHosts()
public String[] getConnectorNames()
public void setConnectorNames(String[] connectors)
connectors - If non null, an array of connector names that this context
will accept a request from.public Object getAttribute(String name)
getAttribute in interface org.mortbay.util.Attributespublic Enumeration getAttributeNames()
getAttributeNames in interface org.mortbay.util.Attributespublic org.mortbay.util.Attributes getAttributes()
public ClassLoader getClassLoader()
public String getClassPath()
public String getContextPath()
public Enumeration getInitParameterNames()
public Map getInitParams()
public String getDisplayName()
public EventListener[] getEventListeners()
public void setEventListeners(EventListener[] eventListeners)
public void addEventListener(EventListener listener)
public boolean isShutdown()
public void setShutdown(boolean shutdown)
setShutdown in interface Server.Gracefulaccepting - true if this context is accepting new requestsprotected void doStart()
throws Exception
doStart in class HandlerWrapperExceptionprotected void doStop()
throws Exception
doStop in class HandlerWrapperExceptionpublic void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException
Handlerhandle in interface Handlerhandle in class HandlerWrappertarget - 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.ERRORIOExceptionServletExceptionprotected boolean isProtectedTarget(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.WebAppContext.isProtectedTarget(String)public void removeAttribute(String name)
removeAttribute in interface org.mortbay.util.Attributespublic void setAttribute(String name, Object value)
setAttribute in interface org.mortbay.util.Attributespublic void setAttributes(org.mortbay.util.Attributes attributes)
attributes - The attributes to set.public void clearAttributes()
clearAttributes in interface org.mortbay.util.Attributespublic void setClassLoader(ClassLoader classLoader)
classLoader - The classLoader to set.public void setContextPath(String contextPath)
contextPath - The _contextPath to set.public void setInitParams(Map initParams)
initParams - The initParams to set.public void setDisplayName(String servletContextName)
servletContextName - The servletContextName to set.public Resource getBaseResource()
public String getResourceBase()
public void setBaseResource(Resource base)
base - The resourceBase to set.public void setResourceBase(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(String[] files)
public 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 String toString()
toString in class AbstractHandlerpublic Class loadClass(String className) throws ClassNotFoundException
ClassNotFoundExceptionpublic String getLocaleEncoding(Locale locale)
locale - a Locale valueString representing the character encoding for
the locale or null if none found.public Resource getResource(String path) throws MalformedURLException
MalformedURLExceptionCopyright © 2009 Mortbay Consulting Pty. Ltd. All Rights Reserved.