Package com.vaadin.swingkit.client
Class VaadinRequestsManager
java.lang.Object
com.vaadin.swingkit.client.VaadinRequestsManager
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidRegisters a request so that a thread can block waiting for a response.voidregisterResponse(String encodedResponse) Register a response returned from a Vaadin view, potentially unblocking any thread already waiting for a response with the same id.<T> TBlock the current thread until a response with the given id is received from a Vaadin view or the timeout expires, whatever happens first.<T> TwaitForResponse(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.
-
Constructor Details
-
VaadinRequestsManager
public VaadinRequestsManager()
-
-
Method Details
-
registerRequest
Registers a request so that a thread can block waiting for a response.- Parameters:
id- the id of the request.
-
registerResponse
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 theInvocationUtilsutility 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 arrivesSwingVaadinException- a custom exception thrown if any problem occurs
-
waitForResponse
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 arrivesSwingVaadinException- a custom exception thrown if any problem occursException
-