Interface RequestManager


public interface RequestManager
Sets up and tears down all logic for processing requests, such as logging, access logging, profiling and publishing RequestStartedEvent and RequestEndedEvent.
  • Method Details

    • doAsRequest

      @Nullable <T, E extends Exception> T doAsRequest(@Nonnull RequestCallback<T,E> callback, @Nonnull RequestInfoProvider requestInfoProvider) throws E
      Sets up and tears down all logic for processing requests.
      Type Parameters:
      T - type of the request
      E - type of exception
      Parameters:
      callback - called after the RequestStartedEvent has been published.
      requestInfoProvider - provides request details such as sessionId, remoteAddress that are used to set up logging.
      Returns:
      the return value of the callback
      Throws:
      E - when RequestCallback.withRequest(RequestContext) throws an exception.
    • getRequestContext

      @Nullable RequestContext getRequestContext()
      Returns:
      the context of the current request. Returns null if there is no current request, for instance when running a task in a background thread.
    • getRequestId

      @Nullable String getRequestId()
      Returns:
      a highly unique (though not guaranteeably unique) request ID. Returns null if there is no current request, for instance when running a task in a background thread.
      Since:
      5.0
      See Also:
    • getRequestMetadata

      @Nullable RequestMetadata getRequestMetadata()
      Returns:
      the metadata of the current request. Returns null if there is no current request.
    • newRequestLocal

      @Nonnull <T> RequestLocal<T> newRequestLocal()
      Creates a new RequestLocal to get/set values in the current RequestContext. Conceptually similar to a ThreadLocal, but tied to the current RequestContext instead of the current thread.
      Type Parameters:
      T - the value type
      Returns:
      the RequestLocal
      Since:
      7.9
    • newRequestLocal

      @Nonnull <T> RequestLocal<T> newRequestLocal(@Nullable Consumer<T> cleanupListener)
      Creates a new RequestLocal to get/set values in the current RequestContext. Conceptually similar to a ThreadLocal, but tied to the current RequestContext instead of the current thread.
      Type Parameters:
      T - the value type
      Parameters:
      cleanupListener - optional listener that is invoked when an RequestContext has completed and all values in the context are removed. The cleanupListener is NOT called if the RequestLocal does not contain a value for the RequestContext that is being wrapped up.
      Returns:
      the RequestLocal
      Since:
      7.9