- All Superinterfaces:
org.eclipse.jetty.util.Attributes,org.eclipse.jetty.util.Decorator,Executor
- All Known Implementing Classes:
ContextHandler.ScopedContext
The context for handling an HTTP request.
Every request has a non-null context, which may initially
be the server context, or
a context provided by a ContextHandler.
A context is also an Executor, which allows tasks to be run by a
thread pool, but scoped to the ClassLoader and any other context property.
Method run(Runnable) is also provided to allow the current thread
to be scoped to the context for the execution of the task.
A Context is also a Decorator, allowing objects to be decorated
in a context scope.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.Attributes
org.eclipse.jetty.util.Attributes.Layer, org.eclipse.jetty.util.Attributes.Lazy, org.eclipse.jetty.util.Attributes.Mapped, org.eclipse.jetty.util.Attributes.Wrapper -
Field Summary
Fields inherited from interface org.eclipse.jetty.util.Attributes
NULL -
Method Summary
Modifier and TypeMethodDescriptionvoidExecutes the given task in a thread scoped to this Context.org.eclipse.jetty.util.resource.Resourceorg.eclipse.jetty.http.MimeTypesdefault StringgetPathInContext(String canonicallyEncodedPath) Returns the URI path scoped to this Context.static StringgetPathInContext(String encodedContextPath, String encodedPath) Returns the URI path scoped to the passed context path.voidRuns the given task in the current thread scoped to this Context.voidRuns the given task in the current thread scoped to this Context and the given Request.Methods inherited from interface org.eclipse.jetty.util.Attributes
asAttributeMap, clearAttributes, getAttribute, getAttributeNameSet, removeAttribute, setAttributeMethods inherited from interface org.eclipse.jetty.util.Decorator
decorate, destroy
-
Method Details
-
getContextPath
String getContextPath()- Returns:
- the encoded context path of this Context
-
getClassLoader
ClassLoader getClassLoader()- Returns:
- the
ClassLoaderassociated with this Context
-
getBaseResource
org.eclipse.jetty.util.resource.Resource getBaseResource()- Returns:
- the base resource used to lookup other resources specified by the request URI path
-
getErrorHandler
Request.Handler getErrorHandler()- Returns:
- the error
Request.Handlerassociated with this Context
-
getVirtualHosts
- Returns:
- a list of virtual host names associated with this Context
-
getMimeTypes
org.eclipse.jetty.http.MimeTypes getMimeTypes()- Returns:
- the mime types associated with this Context
-
execute
Executes the given task in a thread scoped to this Context.
-
run
Runs the given task in the current thread scoped to this Context.
- Parameters:
task- the task to run- See Also:
-
run
Runs the given task in the current thread scoped to this Context and the given Request.
- Parameters:
task- the task to runrequest- the HTTP request to use in the scope
-
getPathInContext
Returns the URI path scoped to this Context.
- Parameters:
canonicallyEncodedPath- a full URI path that should be canonically encoded as perURIUtil.canonicalPath(String)- Returns:
- the URI path scoped to this Context, or
nullif the full path does not match this Context. The empty string is returned if the full path is exactly the context path. - See Also:
-
getTempDirectory
File getTempDirectory()- Returns:
- a non-
nulltemporary directory, configured either for the context, the server or the JVM
-
getPathInContext
Returns the URI path scoped to the passed context path.
For example, if the context path passed is
/ctxthen a path of/ctx/foo/barwill return/foo/bar.- Parameters:
encodedContextPath- The context path that should be canonically encoded as perURIUtil.canonicalPath(String).encodedPath- a full URI path that should be canonically encoded as perURIUtil.canonicalPath(String).- Returns:
- the URI
encodedPathscoped to theencodedContextPath, ornullif theencodedPathdoes not match the context. The empty string is returned if theencodedPathis exactly theencodedContextPath.
-