Class VaadinRequestsManager

java.lang.Object
com.vaadin.swingkit.client.VaadinRequestsManager

public class VaadinRequestsManager extends Object

The VaadinRequestManager correlates the requests sent to Vaadin views with the responses returned from them so that these calls can be treated synchronously.

It uses concurrent maps to keep track of sent requests and returned responses, using their keys to match each other.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Registers a request so that a thread can block waiting for a response.
    void
    registerResponse(String encodedResponse)
    Register a response returned from a Vaadin view, potentially unblocking any thread already waiting for a response with the same id.
    <T> T
    Block the current thread until a response with the given id is received from a Vaadin view or the timeout expires, whatever happens first.
    <T> T
    waitForResponse(String id, long timeout)
    Block the current thread until a response with the given id is received from a Vaadin view or the timeout expires, whatever happens first.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • VaadinRequestsManager

      public VaadinRequestsManager()
  • Method Details

    • registerRequest

      public void registerRequest(String id)
      Registers a request so that a thread can block waiting for a response.
      Parameters:
      id - the id of the request.
    • registerResponse

      public void registerResponse(String encodedResponse)
      Register a response returned from a Vaadin view, potentially unblocking any thread already waiting for a response with the same id.
      Parameters:
      encodedResponse - the response encoded using the InvocationUtils utility class.
    • waitForResponse

      public <T> T waitForResponse(String id, long timeout) throws InterruptedException, SwingVaadinException
      Block the current thread until a response with the given id is received from a Vaadin view or the timeout expires, whatever happens first.
      Type Parameters:
      T - the type of response
      Parameters:
      id - the id of the request that spawned the response.
      timeout - the maximum amount of time to wait in seconds before throwing an exception
      Returns:
      any result object coming from the called method
      Throws:
      InterruptedException - if the thread is interrupted before the response arrives
      SwingVaadinException - a custom exception thrown if any problem occurs
    • waitForResponse

      public <T> T waitForResponse(String id) throws Exception
      Block the current thread until a response with the given id is received from a Vaadin view or the timeout expires, whatever happens first. It uses the timeout set in the currently running Swing Kit configuration.
      Type Parameters:
      T - the type of response
      Parameters:
      id - the id of the request that spawned the response.
      Returns:
      any result object coming from the called method
      Throws:
      InterruptedException - if the thread is interrupted before the response arrives
      SwingVaadinException - a custom exception thrown if any problem occurs
      Exception