|
||||||||||
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 |
---|
LifeCycle.Listener |
Field Summary | |
---|---|
protected ContextHandler.SContext |
_scontext
|
static java.lang.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,
java.lang.String contextPath)
|
|
ContextHandler(java.lang.String contextPath)
|
Method Summary | |
---|---|
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()
|
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()
|
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,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.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(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. use setConnectorNames(String[]) |
void |
setInitParams(java.util.Map initParams)
|
void |
setMaxFormContentSize(int maxSize)
|
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()
|
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 java.lang.String MANAGED_ATTRIBUTES
protected ContextHandler.SContext _scontext
Constructor Detail |
---|
public ContextHandler()
protected ContextHandler(ContextHandler.SContext context)
public ContextHandler(java.lang.String contextPath)
public ContextHandler(HandlerContainer parent, java.lang.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(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 Attributes
public java.util.Enumeration getAttributeNames()
getAttributeNames
in interface Attributes
public 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, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, int dispatch) throws java.io.IOException, javax.servlet.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
javax.servlet.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.
WebAppContext.isProtectedTarget(String)
public void removeAttribute(java.lang.String name)
removeAttribute
in interface Attributes
public void setAttribute(java.lang.String name, java.lang.Object value)
setAttribute
in interface Attributes
public void setAttributes(Attributes attributes)
attributes
- The attributes to set.public void clearAttributes()
clearAttributes
in interface 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)
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
value
String
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)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |