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 paththat is a prefix to all URIs handled by theContext - has an optional list of
virtual hoststhat theContextis applicable to. - has an optional
ClassLoaderthat that is set as theThread context ClassLoaderforThreads handling the request. - is an
Executorthat can execute jobs in with theThread context ClassLoader - is a
Decoratorusing theDecoratedObjectFactorythat can create objects specific to the context. - has the same
temporary directorspecific to the context.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface Attributes
Attributes.Layer, Attributes.Lazy, Attributes.Mapped, Attributes.Synthetic, Attributes.Wrapper -
Field Summary
Fields inherited from interface Attributes
NULL -
Method Summary
Modifier and TypeMethodDescriptionvoidExecutes the given task in a thread scoped to this Context.default StringgetCrossContextDispatchType(Request request) Get any cross context dispatch typedefault 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.default booleanisCrossContextDispatch(Request request) Check cross context dispatch statusvoidRuns 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 Attributes
asAttributeMap, clearAttributes, equals, getAttribute, getAttributeNameSet, hashCode, removeAttribute, setAttribute
-
Method Details
-
getContextPath
String getContextPath()- Returns:
- the encoded context path of this
Contextornull
-
getClassLoader
ClassLoader getClassLoader()- Returns:
- the
ClassLoaderassociated 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.Handlerassociated with this Context
-
getVirtualHosts
-
getMimeTypes
MimeTypes getMimeTypes()- Returns:
- the mime types associated with this Context
-
execute
-
run
Runs the given task in the current thread scoped to this Context.
- Parameters:
task- the task to run- See Also:
-
run
-
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
-
isCrossContextDispatch
Check cross context dispatch status- Parameters:
request- The request to check- Returns:
TrueIFF this contextsupports cross contextand 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 contextand 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
/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.
-