Package org.eclipse.jetty.server
Interface Context
- All Superinterfaces:
Attributes
,Decorator
,Executor
- All Known Implementing Classes:
ContextHandler.ScopedContext
,ServletContextHandler.ServletScopedContext
A context for handling an Request
.
Every request has a non-null
context, which may initially
be the server context
, or
a context provided by a ContextHandler
.
A Context
:
- has an optional
context path
that is a prefix to all URIs handled by theContext
- has an optional list of
virtual hosts
that theContext
is applicable to. - has an optional
ClassLoader
that that is set as theThread context ClassLoader
forThread
s handling the request. - is an
Executor
that can execute jobs in with theThread context ClassLoader
- is a
Decorator
using theDecoratedObjectFactory
that can create objects specific to the context. - has the same
temporary director
specific to the context.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.Attributes
Attributes.Layer, Attributes.Lazy, Attributes.Mapped, Attributes.Synthetic, Attributes.Wrapper
-
Field Summary
Fields inherited from interface org.eclipse.jetty.util.Attributes
NULL
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Executes the given task in a thread scoped to this Context.default String
getCrossContextDispatchType
(Request request) Get any cross context dispatch typedefault String
getPathInContext
(String canonicallyEncodedPath) Returns the URI path scoped to this Context.static String
getPathInContext
(String encodedContextPath, String encodedPath) Returns the URI path scoped to the passed context path.default boolean
isCrossContextDispatch
(Request request) Check cross context dispatch statusvoid
Runs the given task in the current thread scoped to this Context.void
Runs 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, equals, getAttribute, getAttributeNameSet, hashCode, removeAttribute, setAttribute
-
Method Details
-
getContextPath
String getContextPath()- Returns:
- the encoded context path of this
Context
ornull
-
getClassLoader
ClassLoader getClassLoader()- Returns:
- the
ClassLoader
associated with this Context
-
getBaseResource
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.Handler
associated with this Context
-
getVirtualHosts
- Returns:
- a list of virtual host names associated with this Context
-
getMimeTypes
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
null
if 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-
null
temporary directory, configured either for the context, the server or the JVM
-
isCrossContextDispatch
Check cross context dispatch status- Parameters:
request
- The request to check- Returns:
True
IFF this contextsupports cross context
and the passed request is a cross context request.
-
getCrossContextDispatchType
Get any cross context dispatch type- Parameters:
request
- The request to get the type for- Returns:
- A String representation of a dispatcher type iff this context
supports cross context
and the passed request is a cross context request, otherwise null.
-
getPathInContext
Returns the URI path scoped to the passed context path.
For example, if the context path passed is
/ctx
then a path of/ctx/foo/bar
will 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
encodedPath
scoped to theencodedContextPath
, ornull
if theencodedPath
does not match the context. The empty string is returned if theencodedPath
is exactly theencodedContextPath
.
-