Class DefaultWebRequestContext

java.lang.Object
io.fluxcapacitor.javaclient.web.DefaultWebRequestContext
All Implemented Interfaces:
WebRequestContext, io.jooby.Context, io.jooby.DefaultContext, io.jooby.Registry

public class DefaultWebRequestContext extends Object implements io.jooby.DefaultContext, WebRequestContext
Default implementation of WebRequestContext that adapts a DeserializingMessage of type MessageType.WEBREQUEST to a Jooby-compatible Context.

This context serves as the main bridge between Flux Capacitor’s web messaging infrastructure and the Jooby framework’s routing, parameter resolution, and content access APIs. It enables handler matching and invocation based on path, query, form, header, and cookie parameters.

Purpose

DefaultWebRequestContext wraps incoming web request metadata into an object that behaves like a live HTTP request. It can be used during handler method resolution to extract parameter values, match URI paths, handle routing with method + origin specificity, and access request body, headers, etc.

Internals

  • Backed by a DeserializingMessage representing a WEBREQUEST
  • Implements Jooby’s DefaultContext to take advantage of its form/query/header abstractions
  • Supports delayed body deserialization using a Supplier<byte[]>
  • Provides metadata-based implementations of headers, cookies, and remote address resolution
  • Can be accessed statically from getCurrentWebRequestContext()

Usage in Routing

Used primarily by WebHandlerMatcher, this context provides the foundation for matching WebPatterns and routing to appropriate handler methods.

Extensibility

While this implementation currently delegates most parsing and matching to Jooby, the abstraction is intentionally based on the WebRequestContext interface to allow future replacement of Jooby with another HTTP framework without affecting the rest of the dispatching system.

Many Jooby methods are stubbed or unsupported, as Flux only uses a subset of Jooby's APIs for request introspection (not response handling).

See Also:
  • Method Details

    • getCurrentWebRequestContext

      public static DefaultWebRequestContext getCurrentWebRequestContext()
      Returns the current DefaultWebRequestContext from the active DeserializingMessage, or null if no such message is available or it is not a MessageType.WEBREQUEST.

      This method provides a convenient way to access the web request context during handler invocation, filtering, or logging without needing to explicitly pass it around.

      Returns:
      the current DefaultWebRequestContext, or null if unavailable
      See Also:
    • getWebRequestContext

      public static DefaultWebRequestContext getWebRequestContext(DeserializingMessage message)
      Creates or retrieves a DefaultWebRequestContext from the given DeserializingMessage.

      Internally caches the context in the message so that repeated lookups are efficient. This method should only be used with messages of type MessageType.WEBREQUEST; otherwise, an IllegalArgumentException is thrown.

      Parameters:
      message - a deserialized WEBREQUEST message
      Returns:
      a DefaultWebRequestContext wrapping the request metadata and body
      Throws:
      IllegalArgumentException - if the message type is not WEBREQUEST
      See Also:
    • pathMap

      @NotNull public Map<String,String> pathMap()
      Specified by:
      pathMap in interface io.jooby.Context
    • getParameter

      public ParameterValue getParameter(String name, WebParameterSource... sources)
      Description copied from interface: WebRequestContext
      Retrieves the value of a specified parameter from the given sources in a web request.
      Specified by:
      getParameter in interface WebRequestContext
      Parameters:
      name - the name of the parameter to retrieve. Must not be null.
      sources - the sources to look for the parameter, such as PATH, QUERY, HEADER, COOKIE, or FORM. If no sources are provided, the method may default to a predefined set of sources.
      Returns:
      the ParameterValue associated with the specified parameter name and sources, or an empty ParameterValue if the parameter is not found.
    • getProtocol

      @NotNull public String getProtocol()
      Specified by:
      getProtocol in interface io.jooby.Context
    • getClientCertificates

      @NotNull public List<Certificate> getClientCertificates()
      Specified by:
      getClientCertificates in interface io.jooby.Context
    • getScheme

      @NotNull public String getScheme()
      Specified by:
      getScheme in interface io.jooby.Context
    • setRemoteAddress

      @NotNull public io.jooby.Context setRemoteAddress(@NotNull String remoteAddress)
      Specified by:
      setRemoteAddress in interface io.jooby.Context
    • setHost

      @NotNull public io.jooby.Context setHost(@NotNull String host)
      Specified by:
      setHost in interface io.jooby.Context
    • setPort

      @NotNull public io.jooby.Context setPort(int port)
      Specified by:
      setPort in interface io.jooby.Context
    • setScheme

      @NotNull public io.jooby.Context setScheme(@NotNull String scheme)
      Specified by:
      setScheme in interface io.jooby.Context
    • isInIoThread

      public boolean isInIoThread()
      Specified by:
      isInIoThread in interface io.jooby.Context
    • dispatch

      @NotNull public io.jooby.Context dispatch(@NotNull Runnable action)
      Specified by:
      dispatch in interface io.jooby.Context
    • dispatch

      @NotNull public io.jooby.Context dispatch(@NotNull Executor executor, @NotNull Runnable action)
      Specified by:
      dispatch in interface io.jooby.Context
    • detach

      @NotNull public io.jooby.Context detach(@NotNull io.jooby.Route.Handler next) throws Exception
      Specified by:
      detach in interface io.jooby.Context
      Throws:
      Exception
    • upgrade

      @NotNull public io.jooby.Context upgrade(@NotNull io.jooby.WebSocket.Initializer handler)
      Specified by:
      upgrade in interface io.jooby.Context
    • upgrade

      @NotNull public io.jooby.Context upgrade(@NotNull io.jooby.ServerSentEmitter.Handler handler)
      Specified by:
      upgrade in interface io.jooby.Context
    • setResponseHeader

      @NotNull public io.jooby.Context setResponseHeader(@NotNull String name, @NotNull String value)
      Specified by:
      setResponseHeader in interface io.jooby.Context
    • removeResponseHeader

      @NotNull public io.jooby.Context removeResponseHeader(@NotNull String name)
      Specified by:
      removeResponseHeader in interface io.jooby.Context
    • removeResponseHeaders

      @NotNull public io.jooby.Context removeResponseHeaders()
      Specified by:
      removeResponseHeaders in interface io.jooby.Context
    • setResponseLength

      @NotNull public io.jooby.Context setResponseLength(long length)
      Specified by:
      setResponseLength in interface io.jooby.Context
    • getResponseHeader

      @Nullable public String getResponseHeader(@NotNull String name)
      Specified by:
      getResponseHeader in interface io.jooby.Context
    • getResponseLength

      public long getResponseLength()
      Specified by:
      getResponseLength in interface io.jooby.Context
    • isResponseStarted

      public boolean isResponseStarted()
      Specified by:
      isResponseStarted in interface io.jooby.Context
    • getResetHeadersOnError

      public boolean getResetHeadersOnError()
      Specified by:
      getResetHeadersOnError in interface io.jooby.Context
    • getResponseType

      @NotNull public io.jooby.MediaType getResponseType()
      Specified by:
      getResponseType in interface io.jooby.Context
    • setResponseCode

      @NotNull public io.jooby.Context setResponseCode(int statusCode)
      Specified by:
      setResponseCode in interface io.jooby.Context
    • getResponseCode

      @NotNull public io.jooby.StatusCode getResponseCode()
      Specified by:
      getResponseCode in interface io.jooby.Context
    • responseStream

      @NotNull public OutputStream responseStream()
      Specified by:
      responseStream in interface io.jooby.Context
    • responseSender

      @NotNull public io.jooby.Sender responseSender()
      Specified by:
      responseSender in interface io.jooby.Context
    • responseWriter

      @NotNull public PrintWriter responseWriter(@NotNull io.jooby.MediaType contentType, @Nullable Charset charset)
      Specified by:
      responseWriter in interface io.jooby.Context
    • getRouter

      @NotNull public io.jooby.Router getRouter()
      Specified by:
      getRouter in interface io.jooby.Context
    • setMethod

      @NotNull public io.jooby.Context setMethod(@NotNull String method)
      Specified by:
      setMethod in interface io.jooby.Context
    • setRequestPath

      @NotNull public io.jooby.Context setRequestPath(@NotNull String path)
      Specified by:
      setRequestPath in interface io.jooby.Context
    • send

      @NotNull public io.jooby.Context send(@NotNull String data, @NotNull Charset charset)
      Specified by:
      send in interface io.jooby.Context
    • send

      @NotNull public io.jooby.Context send(@NotNull byte[] data)
      Specified by:
      send in interface io.jooby.Context
    • send

      @NotNull public io.jooby.Context send(@NotNull ByteBuffer data)
      Specified by:
      send in interface io.jooby.Context
    • send

      @NotNull public io.jooby.Context send(@NotNull io.jooby.buffer.DataBuffer data)
      Specified by:
      send in interface io.jooby.Context
    • send

      @NotNull public io.jooby.Context send(@NotNull ByteBuffer[] data)
      Specified by:
      send in interface io.jooby.Context
    • send

      @NotNull public io.jooby.Context send(@NotNull ReadableByteChannel channel)
      Specified by:
      send in interface io.jooby.Context
    • send

      @NotNull public io.jooby.Context send(@NotNull InputStream input)
      Specified by:
      send in interface io.jooby.Context
    • send

      @NotNull public io.jooby.Context send(@NotNull FileChannel file)
      Specified by:
      send in interface io.jooby.Context
    • send

      @NotNull public io.jooby.Context send(@NotNull io.jooby.StatusCode statusCode)
      Specified by:
      send in interface io.jooby.Context
    • setResetHeadersOnError

      @NotNull public io.jooby.Context setResetHeadersOnError(boolean value)
      Specified by:
      setResetHeadersOnError in interface io.jooby.Context
    • setResponseCookie

      @NotNull public io.jooby.Context setResponseCookie(@NotNull io.jooby.Cookie cookie)
      Specified by:
      setResponseCookie in interface io.jooby.Context
    • setResponseType

      @NotNull public io.jooby.Context setResponseType(@NotNull String contentType)
      Specified by:
      setResponseType in interface io.jooby.Context
    • setResponseType

      @NotNull public io.jooby.Context setResponseType(@NotNull io.jooby.MediaType contentType, @Nullable Charset charset)
      Specified by:
      setResponseType in interface io.jooby.Context
    • setDefaultResponseType

      @NotNull public io.jooby.Context setDefaultResponseType(@NotNull io.jooby.MediaType contentType)
      Specified by:
      setDefaultResponseType in interface io.jooby.Context
    • onComplete

      @NotNull public io.jooby.Context onComplete(@NotNull io.jooby.Route.Complete task)
      Specified by:
      onComplete in interface io.jooby.Context
    • matchesAny

      public boolean matchesAny(Collection<String> urlPatterns)