Interface RequestContext

All Known Implementing Classes:
RequestHandler

public interface RequestContext
A request context is the asynchronous interface for working with a pending request. The context must be provided when sending a signal, and the RequestSink is obligated to send all replies to this context. The context will also be notified if the RequestSink closes the request, or notifies about an error.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Add a RequestListener to context.
    boolean
    Add a signal response to give back to requesting client
    void
    Signal end of stream (the current context holder will not provide any more data).
    boolean
     
    boolean
    keepAlive(long until)
    Request that this request should be kept alive a bit longer
    void
    Notify signal context that server has closed this request.
    void
    Notify signal context that an error has occurred while waiting for data
    void
    Remove a RequestListener from context
  • Method Details

    • isClosed

      boolean isClosed()
      Returns:
      true if this request is closed down (will not accept any more responses)
    • keepAlive

      boolean keepAlive(long until)
      Request that this request should be kept alive a bit longer
      Parameters:
      until - Ask this request to keep open at least until this timestamp
      Returns:
      true if the request is granted (will not guarantee that endpoint clients keep this up)
    • notifyError

      void notifyError(Throwable e)
      Notify signal context that an error has occurred while waiting for data
      Parameters:
      e - exception that was caught
    • notifyClose

      void notifyClose()
      Notify signal context that server has closed this request. The request may already be closed on the client side.
    • addListener

      void addListener(RequestListener listener)
      Add a RequestListener to context. A context implementation should notify any registered listeners about relevant events.
      Parameters:
      listener - listener to add
    • removeListener

      void removeListener(RequestListener listener)
      Remove a RequestListener from context
      Parameters:
      listener - listener to remove
    • addResponse

      boolean addResponse(Message msg)
      Add a signal response to give back to requesting client
      Parameters:
      msg - the response message to add
      Returns:
      true if the response message was accepted, false if it was discarded
    • endOfStream

      void endOfStream()
      Signal end of stream (the current context holder will not provide any more data).