|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.server.handler.AbstractHandler
org.eclipse.jetty.server.handler.AbstractHandlerContainer
org.eclipse.jetty.server.handler.HandlerWrapper
org.eclipse.jetty.server.handler.ScopedHandler
org.eclipse.jetty.server.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.eclipse.jetty.server.context.ManagedAttributes" is set to a comma 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.Context
Context. |
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle |
---|
AbstractLifeCycle.AbstractLifeCycleListener |
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle |
---|
LifeCycle.Listener |
Field Summary | |
---|---|
protected ContextHandler.Context |
_scontext
|
static java.lang.String |
MANAGED_ATTRIBUTES
If a context attribute with this name is set, it is interpreted as a comma separated list of attribute name. |
Fields inherited from class org.eclipse.jetty.server.handler.ScopedHandler |
---|
_nextScope, _outerScope |
Fields inherited from class org.eclipse.jetty.server.handler.HandlerWrapper |
---|
_handler |
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle |
---|
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING |
Constructor Summary | |
---|---|
|
ContextHandler()
|
protected |
ContextHandler(ContextHandler.Context context)
|
|
ContextHandler(HandlerContainer parent,
java.lang.String contextPath)
|
|
ContextHandler(java.lang.String contextPath)
|
Method Summary | |
---|---|
void |
addEventListener(java.util.EventListener listener)
Add a context event listeners. |
void |
addLocaleEncoding(java.lang.String locale,
java.lang.String encoding)
|
boolean |
checkContext(java.lang.String target,
Request baseRequest,
javax.servlet.http.HttpServletResponse response)
|
void |
checkManagedAttribute(java.lang.String name,
java.lang.Object value)
|
void |
clearAttributes()
|
void |
doHandle(java.lang.String target,
Request baseRequest,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
void |
doScope(java.lang.String target,
Request baseRequest,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
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.Context |
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<java.lang.String,java.lang.String> |
getInitParams()
|
java.lang.String |
getLocaleEncoding(java.util.Locale locale)
Get the character encoding for a locale. |
Logger |
getLogger()
|
int |
getMaxFormContentSize()
|
MimeTypes |
getMimeTypes()
|
Resource |
getResource(java.lang.String path)
|
java.lang.String |
getResourceBase()
|
java.util.Set<java.lang.String> |
getResourcePaths(java.lang.String path)
|
ContextHandler.Context |
getServletContext()
|
java.lang.String[] |
getVirtualHosts()
Get the virtual hosts for the context. |
java.lang.String[] |
getWelcomeFiles()
|
void |
handle(java.lang.Runnable runnable)
|
boolean |
isAliases()
|
boolean |
isAvailable()
|
boolean |
isCompactPath()
|
protected boolean |
isProtectedTarget(java.lang.String target)
Check the target. |
boolean |
isShutdown()
|
java.lang.Class<?> |
loadClass(java.lang.String className)
|
Resource |
newResource(java.lang.String url)
Convert URL to Resource wrapper for Resource.newResource(String) enables extensions to
provide alternate resource implementations. |
Resource |
newResource(java.net.URL url)
Convert URL to Resource wrapper for Resource.newResource(URL) enables extensions to
provide alternate resource implementations. |
void |
removeAttribute(java.lang.String name)
|
void |
setAliases(boolean aliases)
|
void |
setAllowNullPathInfo(boolean allowNullPathInfo)
|
void |
setAttribute(java.lang.String name,
java.lang.Object value)
|
void |
setAttributes(Attributes attributes)
|
void |
setAvailable(boolean available)
Set Available status. |
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)
Set the context event listeners. |
void |
setHosts(java.lang.String[] hosts)
Deprecated. use setConnectorNames(String[]) |
void |
setLogger(Logger logger)
|
void |
setManagedAttribute(java.lang.String name,
java.lang.Object value)
|
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()
Extensible startContext. |
java.lang.String |
toString()
|
Methods inherited from class org.eclipse.jetty.server.handler.ScopedHandler |
---|
handle, never, nextHandle, nextScope |
Methods inherited from class org.eclipse.jetty.server.handler.HandlerWrapper |
---|
expandChildren, getHandler, getHandlers, setHandler |
Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandlerContainer |
---|
dump, expandHandler, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass |
Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandler |
---|
destroy, dump, getServer |
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle |
---|
addLifeCycleListener, getState, 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.eclipse.jetty.server.Handler |
---|
destroy, getServer, handle |
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle |
---|
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop |
Field Detail |
---|
public static final java.lang.String MANAGED_ATTRIBUTES
setManagedAttribute(String, Object)
,
which typically initiates the creation of a JMX MBean for the attribute value.
protected ContextHandler.Context _scontext
Constructor Detail |
---|
public ContextHandler()
protected ContextHandler(ContextHandler.Context context)
public ContextHandler(java.lang.String contextPath)
public ContextHandler(HandlerContainer parent, java.lang.String contextPath)
Method Detail |
---|
public static ContextHandler.Context getCurrentContext()
public ContextHandler.Context 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()
@Deprecated public void setHosts(java.lang.String[] hosts)
setConnectorNames(String[])
@Deprecated 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<java.lang.String,java.lang.String> getInitParams()
public java.lang.String getDisplayName()
public java.util.EventListener[] getEventListeners()
public void setEventListeners(java.util.EventListener[] eventListeners)
ServletContextListener
,
ServletContextAttributeListener
,
ServletRequestListener
,
ServletRequestAttributeListener
public void addEventListener(java.util.EventListener listener)
ServletContextListener
,
ServletContextAttributeListener
,
ServletRequestListener
,
ServletRequestAttributeListener
public boolean isShutdown()
public void setShutdown(boolean shutdown)
setShutdown
in interface Server.Graceful
shutdown
- true if this context is (not?) accepting new requestspublic boolean isAvailable()
public void setAvailable(boolean available)
public Logger getLogger()
public void setLogger(Logger logger)
protected void doStart() throws java.lang.Exception
doStart
in class ScopedHandler
java.lang.Exception
HandlerWrapper.doStart()
protected void startContext() throws java.lang.Exception
doStart()
instead of a
call to super.doStart(). This allows derived classes to insert additional
handling (Eg configuration) before the call to super.doStart by this method
will start contained handlers.
java.lang.Exception
ContextHandler.Context
protected void doStop() throws java.lang.Exception
doStop
in class HandlerWrapper
java.lang.Exception
public boolean checkContext(java.lang.String target, Request baseRequest, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
java.io.IOException
javax.servlet.ServletException
public void doScope(java.lang.String target, Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
doScope
in class ScopedHandler
java.io.IOException
javax.servlet.ServletException
ScopedHandler.doScope(java.lang.String, org.eclipse.jetty.server.Request, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
public void doHandle(java.lang.String target, Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
doHandle
in class ScopedHandler
java.io.IOException
javax.servlet.ServletException
ScopedHandler.doHandle(java.lang.String, org.eclipse.jetty.server.Request, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
public void handle(java.lang.Runnable runnable)
protected boolean isProtectedTarget(java.lang.String target)
ScopedHandler.handle(String, Request, HttpServletRequest, HttpServletResponse)
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 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 checkManagedAttribute(java.lang.String name, java.lang.Object value)
public void setManagedAttribute(java.lang.String name, java.lang.Object value)
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 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 boolean isAliases()
public void setAliases(boolean aliases)
aliases
- aliases are allowedpublic 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 Resource newResource(java.net.URL url) throws java.io.IOException
Resource.newResource(URL)
enables extensions to
provide alternate resource implementations.
java.io.IOException
public Resource newResource(java.lang.String url) throws java.io.IOException
Resource.newResource(String)
enables extensions to
provide alternate resource implementations.
java.io.IOException
public java.util.Set<java.lang.String> getResourcePaths(java.lang.String path)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |