|
|||||||||
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
public class ContextHandler
ContextHandler. This handler wraps a call to handle by setting the context and servlet path, plus setting the context classloader.
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.
Nested Class Summary | |
---|---|
class |
ContextHandler.SContext
Context. |
Nested classes/interfaces inherited from interface org.mortbay.component.LifeCycle |
---|
org.mortbay.component.LifeCycle.Listener |
Field Summary | |
---|---|
protected ContextHandler.SContext |
_scontext
|
static String |
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 |
---|
ALL, DEFAULT, ERROR, FORWARD, INCLUDE, REQUEST |
Constructor Summary | |
---|---|
|
ContextHandler()
|
protected |
ContextHandler(ContextHandler.SContext context)
|
|
ContextHandler(HandlerContainer parent,
String contextPath)
|
|
ContextHandler(String contextPath)
|
Method Summary | |
---|---|
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. use setConnectorNames(String[]) |
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()
|
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 MANAGED_ATTRIBUTES
protected ContextHandler.SContext _scontext
Constructor Detail |
---|
public ContextHandler()
protected ContextHandler(ContextHandler.SContext context)
public ContextHandler(String contextPath)
public ContextHandler(HandlerContainer parent, String contextPath)
Method Detail |
---|
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(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.Attributes
public Enumeration getAttributeNames()
getAttributeNames
in interface org.mortbay.util.Attributes
public org.mortbay.util.Attributes getAttributes()
public ClassLoader getClassLoader()
public String getClassPath()
public String getContextPath()
public String getInitParameter(String name)
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.Graceful
accepting
- true if this context is accepting new requestsprotected void doStart() throws Exception
doStart
in class HandlerWrapper
Exception
protected void startContext() throws Exception
Exception
protected void doStop() throws Exception
doStop
in class HandlerWrapper
Exception
public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws 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
IOException
ServletException
protected 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.Attributes
public void setAttribute(String name, 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(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 AbstractHandler
public Class loadClass(String className) throws ClassNotFoundException
ClassNotFoundException
public void addLocaleEncoding(String locale, String encoding)
public String getLocaleEncoding(Locale locale)
locale
- a Locale
value
String
representing the character encoding for
the locale or null if none found.public Resource getResource(String path) throws MalformedURLException
MalformedURLException
public Set getResourcePaths(String path)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |