Top Description Fields Methods
org.eclipse.jetty.server

public Interface Context

extends Attributes, Decorator, Executor
Known Direct Implementers
org.eclipse.jetty.server.Server.ServerContext, org.eclipse.jetty.server.handler.ContextHandler.ScopedContext
Imports
java.io.File, java.util.List, java.util.concurrent.Executor, org.eclipse.jetty.http.MimeTypes, org.eclipse.jetty.server.handler.ContextHandler, org.eclipse.jetty.util.Attributes, .DecoratedObjectFactory, .Decorator, org.eclipse.jetty.util.resource.Resource

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:

See Also
Server#getContext()

Field Summary

Inherited from org.eclipse.jetty.util.Attributes:
NULL

Method Summary

Modifier and TypeMethod and Description
public void
execute(Runnable
the task to run
task
)

Redeclares java.util.concurrent.Executor.execute.

Executes the given task in a thread scoped to this Context.

public Resource
getBaseResource()

Returns: the base resource used to lookup other resources specified by the request URI path

public ClassLoader
getClassLoader()

Returns: the ClassLoader associated with this Context

public String
getContextPath()

Returns: the encoded context path of this Context or null

public Request.Handler
getErrorHandler()

Returns: the error Request.Handler associated with this Context

public MimeTypes
getMimeTypes()

Returns: the mime types associated with this Context

public default 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.
getPathInContext
(String
a full URI path that should be canonically encoded as per org.eclipse.jetty.util.URIUtil#canonicalPath(String)
canonicallyEncodedPath
)

Returns the URI path scoped to this Context.

public static String

Returns:

the URI encodedPath scoped to the encodedContextPath, or null if the encodedPath does not match the context. The empty string is returned if the encodedPath is exactly the encodedContextPath.
getPathInContext
(String
The context path that should be canonically encoded as per org.eclipse.jetty.util.URIUtil#canonicalPath(String).
encodedContextPath
,
String
a full URI path that should be canonically encoded as per org.eclipse.jetty.util.URIUtil#canonicalPath(String).
encodedPath
)

Returns the URI path scoped to the passed context path.

public File
getTempDirectory()

Returns: a non-null temporary directory, configured either for the context, the server or the JVM

public List<String>
getVirtualHosts()

Returns: a list of virtual host names associated with this Context

public void
run(Runnable
the task to run
task
)

Runs the given task in the current thread scoped to this Context.

public void
run(Runnable
the task to run
task
,
Request
the HTTP request to use in the scope
request
)

Runs the given task in the current thread scoped to this Context and the given Request.

Inherited from org.eclipse.jetty.util.Attributes:
asAttributeMapclearAttributesequalsequalsgetAttributegetAttributeNameSethashCodehashCoderemoveAttributesetAttributeunwrapunwrap
Inherited from org.eclipse.jetty.util.Decorator:
decoratedestroy

Method Detail

executeback to summary
public void execute(Runnable task)

Redeclares java.util.concurrent.Executor.execute.

Executes the given task in a thread scoped to this Context.

Parameters
task:Runnable

the task to run

Annotations
@Override
See Also
run(Runnable)
getBaseResourceback to summary
public Resource getBaseResource()
Returns:Resource

the base resource used to lookup other resources specified by the request URI path

getClassLoaderback to summary
public ClassLoader getClassLoader()
Returns:ClassLoader

the ClassLoader associated with this Context

getContextPathback to summary
public String getContextPath()
Returns:String

the encoded context path of this Context or null

getErrorHandlerback to summary
public Request.Handler getErrorHandler()
Returns:Request.Handler

the error Request.Handler associated with this Context

getMimeTypesback to summary
public MimeTypes getMimeTypes()
Returns:MimeTypes

the mime types associated with this Context

getPathInContextback to summary
public default String getPathInContext(String canonicallyEncodedPath)

Returns the URI path scoped to this Context.

Parameters
canonicallyEncodedPath:String

a full URI path that should be canonically encoded as per org.eclipse.jetty.util.URIUtil#canonicalPath(String)

Returns:String

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
getPathInContext(String, String)
getPathInContextback to summary
public static String getPathInContext(String encodedContextPath, String encodedPath)

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:String

The context path that should be canonically encoded as per org.eclipse.jetty.util.URIUtil#canonicalPath(String).

encodedPath:String

a full URI path that should be canonically encoded as per org.eclipse.jetty.util.URIUtil#canonicalPath(String).

Returns:String

the URI encodedPath scoped to the encodedContextPath, or null if the encodedPath does not match the context. The empty string is returned if the encodedPath is exactly the encodedContextPath.

getTempDirectoryback to summary
public File getTempDirectory()
Returns:File

a non-null temporary directory, configured either for the context, the server or the JVM

getVirtualHostsback to summary
public List<String> getVirtualHosts()
Returns:List<String>

a list of virtual host names associated with this Context

runback to summary
public void run(Runnable task)

Runs the given task in the current thread scoped to this Context.

Parameters
task:Runnable

the task to run

See Also
run(Runnable, Request)
runback to summary
public void run(Runnable task, Request request)

Runs the given task in the current thread scoped to this Context and the given Request.

Parameters
task:Runnable

the task to run

request:Request

the HTTP request to use in the scope