|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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 String |
MANAGED_ATTRIBUTES
|
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,
String contextPath)
|
|
ContextHandler(String contextPath)
|
Method Summary | |
---|---|
void |
addEventListener(EventListener listener)
Add a context event listeners. |
void |
addLocaleEncoding(String locale,
String encoding)
|
boolean |
checkContext(String target,
Request baseRequest,
HttpServletResponse response)
|
void |
clearAttributes()
|
void |
doHandle(String target,
Request baseRequest,
HttpServletRequest request,
HttpServletResponse response)
|
void |
doScope(String target,
Request baseRequest,
HttpServletRequest request,
HttpServletResponse response)
|
protected void |
doStart()
|
protected void |
doStop()
|
boolean |
getAllowNullPathInfo()
|
Object |
getAttribute(String name)
|
Enumeration |
getAttributeNames()
|
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.Context |
getCurrentContext()
Get the current ServletContext implementation. |
String |
getDisplayName()
|
ErrorHandler |
getErrorHandler()
|
EventListener[] |
getEventListeners()
|
String[] |
getHosts()
Deprecated. |
String |
getInitParameter(String name)
|
Enumeration |
getInitParameterNames()
|
Map<String,String> |
getInitParams()
|
String |
getLocaleEncoding(Locale locale)
Get the character encoding for a locale. |
Logger |
getLogger()
|
int |
getMaxFormContentSize()
|
MimeTypes |
getMimeTypes()
|
Resource |
getResource(String path)
|
String |
getResourceBase()
|
Set<String> |
getResourcePaths(String path)
|
ContextHandler.Context |
getServletContext()
|
String[] |
getVirtualHosts()
Get the virtual hosts for the context. |
String[] |
getWelcomeFiles()
|
void |
handle(Runnable runnable)
|
boolean |
isAliases()
|
boolean |
isAvailable()
|
boolean |
isCompactPath()
|
protected boolean |
isProtectedTarget(String target)
Check the target. |
boolean |
isShutdown()
|
Class<?> |
loadClass(String className)
|
Resource |
newResource(String url)
Convert URL to Resource wrapper for Resource.newResource(String) enables extensions to
provide alternate resource implementations. |
Resource |
newResource(URL url)
Convert URL to Resource wrapper for Resource.newResource(URL) enables extensions to
provide alternate resource implementations. |
void |
removeAttribute(String name)
|
void |
setAliases(boolean aliases)
|
void |
setAllowNullPathInfo(boolean allowNullPathInfo)
|
void |
setAttribute(String name,
Object value)
|
void |
setAttributes(Attributes attributes)
|
void |
setAvailable(boolean available)
Set Available status. |
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)
Set the context event listeners. |
void |
setHosts(String[] hosts)
Deprecated. use setConnectorNames(String[]) |
void |
setInitParams(Map<String,String> initParams)
|
void |
setLogger(Logger logger)
|
void |
setMaxFormContentSize(int maxSize)
|
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()
Extensible startContext. |
String |
toString()
|
Methods inherited from class org.eclipse.jetty.server.handler.ScopedHandler |
---|
handle, 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 String MANAGED_ATTRIBUTES
protected ContextHandler.Context _scontext
Constructor Detail |
---|
public ContextHandler()
protected ContextHandler(ContextHandler.Context context)
public ContextHandler(String contextPath)
public ContextHandler(HandlerContainer parent, 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(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()
@Deprecated public void setHosts(String[] hosts)
setConnectorNames(String[])
@Deprecated 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 Attributes
public Enumeration getAttributeNames()
getAttributeNames
in interface Attributes
public Attributes getAttributes()
public ClassLoader getClassLoader()
public String getClassPath()
public String getContextPath()
public String getInitParameter(String name)
public Enumeration getInitParameterNames()
public Map<String,String> getInitParams()
public String getDisplayName()
public EventListener[] getEventListeners()
public void setEventListeners(EventListener[] eventListeners)
ServletContextListener
,
ServletContextAttributeListener
,
ServletRequestListener
,
ServletRequestAttributeListener
public void addEventListener(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 Exception
doStart
in class ScopedHandler
Exception
HandlerWrapper.doStart()
protected void startContext() throws 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.
Exception
ContextHandler.Context
protected void doStop() throws Exception
doStop
in class HandlerWrapper
Exception
public boolean checkContext(String target, Request baseRequest, HttpServletResponse response) throws IOException, ServletException
IOException
ServletException
public void doScope(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
doScope
in class ScopedHandler
IOException
ServletException
ScopedHandler.doScope(java.lang.String, org.eclipse.jetty.server.Request, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
public void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
doHandle
in class ScopedHandler
IOException
ServletException
ScopedHandler.doHandle(java.lang.String, org.eclipse.jetty.server.Request, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
public void handle(Runnable runnable)
protected boolean isProtectedTarget(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(String name)
removeAttribute
in interface Attributes
public void setAttribute(String name, 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(ClassLoader classLoader)
classLoader
- The classLoader to set.public void setContextPath(String contextPath)
contextPath
- The _contextPath to set.public void setInitParams(Map<String,String> 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 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(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)
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 Resource newResource(URL url) throws IOException
Resource.newResource(URL)
enables extensions to
provide alternate resource implementations.
IOException
public Resource newResource(String url) throws IOException
Resource.newResource(String)
enables extensions to
provide alternate resource implementations.
IOException
public Set<String> getResourcePaths(String path)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |