Interface Context

All Superinterfaces:
org.eclipse.jetty.util.Attributes, org.eclipse.jetty.util.Decorator, Executor
All Known Implementing Classes:
ContextHandler.ScopedContext

public interface Context extends org.eclipse.jetty.util.Attributes, org.eclipse.jetty.util.Decorator, Executor

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:
  • 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.Synthetic, org.eclipse.jetty.util.Attributes.Wrapper
  • Field Summary

    Fields inherited from interface org.eclipse.jetty.util.Attributes

    NULL
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Executes the given task in a thread scoped to this Context.
    org.eclipse.jetty.util.resource.Resource
     
     
     
    default String
    Get any cross context dispatch type
     
    org.eclipse.jetty.http.MimeTypes
     
    default 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
    Check cross context dispatch status
    void
    run(Runnable task)
    Runs the given task in the current thread scoped to this Context.
    void
    run(Runnable task, Request request)
    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

    Methods inherited from interface org.eclipse.jetty.util.Decorator

    decorate, destroy
  • Method Details

    • getContextPath

      String getContextPath()
      Returns:
      the encoded context path of this Context or null
    • getClassLoader

      ClassLoader getClassLoader()
      Returns:
      the ClassLoader associated 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.Handler associated with this Context
    • getVirtualHosts

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

      void execute(Runnable task)

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

      Specified by:
      execute in interface Executor
      Parameters:
      task - the task to run
      See Also:
    • run

      void run(Runnable task)

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

      Parameters:
      task - the task to run
      See Also:
    • run

      void run(Runnable task, Request request)

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

      Parameters:
      task - the task to run
      request - the HTTP request to use in the scope
    • getPathInContext

      default String getPathInContext(String canonicallyEncodedPath)

      Returns the URI path scoped to this Context.

      Parameters:
      canonicallyEncodedPath - a full URI path that should be canonically encoded as per URIUtil.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

      default boolean isCrossContextDispatch(Request request)
      Check cross context dispatch status
      Parameters:
      request - The request to check
      Returns:
      True IFF this context supports cross context and the passed request is a cross context request.
    • getCrossContextDispatchType

      default String getCrossContextDispatchType(Request request)
      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

      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 - The context path that should be canonically encoded as per URIUtil.canonicalPath(String).
      encodedPath - a full URI path that should be canonically encoded as per URIUtil.canonicalPath(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.