Class ResponseHistory

java.lang.Object
org.eclipse.scout.rt.ui.html.ResponseHistory

@Bean public class ResponseHistory extends Object
Collects JSON responses and their corresponding request sequence number and response sequence number until they are acknowledged by the client. A maximum of 10 responses is stored in the history.

This class is thread-safe.

  • Constructor Details

    • ResponseHistory

      public ResponseHistory()
  • Method Details

    • getUiSession

      public UiSession getUiSession()
    • withUiSession

      public ResponseHistory withUiSession(UiSession uiSession)
    • getUiSessionId

      protected String getUiSessionId()
    • registerResponse

      public void registerResponse(Long responseSequenceNo, JSONObject response, Long requestSequenceNo)
      Stores the given response in the history, along with the response sequence number. If a request sequence number is provided, a mapping between those sequence numbers is stored as well. This allows to retrieve the response by request sequence number.

      If the history is already full, the oldest entry is discarded.

      Parameters:
      responseSequenceNo - The sequence number of the response to remember (mandatory)
      response - The response to remember (mandatory)
      requestSequenceNo - The sequence number of the request that caused the response (optional)
      Throws:
      org.eclipse.scout.rt.platform.util.Assertions.AssertionException - if mandatory arguments are null
    • confirmResponseProcessed

      public void confirmResponseProcessed(Long confirmedResponseSequenceNo)
      Confirms that the response with the given response sequence number has been successfully processed by the client. The response is removed from the history. All responses that are older (i.e. have a lower response sequence number) and the "response - request" mappings are automatically removed as well.
      Throws:
      org.eclipse.scout.rt.platform.util.Assertions.AssertionException - if the argument is null
    • toSyncResponse

      public JSONObject toSyncResponse()
      Combines all responses currently contained in the history into one new JSON object.
    • getResponseSequenceNo

      public Long getResponseSequenceNo(Long requestSequenceNo)
      Returns:
      the response sequence number that corresponds to the given request sequence number (or null if no such mapping exists in the history)
    • getRequestSequenceNo

      public Long getRequestSequenceNo(Long responseSequenceNo)
      Returns:
      the request sequence number that corresponds to the given response sequence number (or null if no such mapping exists in the history)
    • getResponse

      public JSONObject getResponse(Long responseSequenceNo)
      Returns:
      the response with the given response sequence number (or null if no response with this sequence number exists in the history)
    • getResponseForRequest

      public JSONObject getResponseForRequest(Long requestSequenceNo)
      Returns:
      the response that was sent as answer for the request with the given request sequence number (or null if no response for this request exists in the history)
    • size

      public int size()
      Returns:
      the number of responses in the history
    • toString

      public String toString()
      Overrides:
      toString in class Object