ServiceInvocation.create("Load data ...", () -> myService.loadData().execute())
.onSuccess(data -> listView.getItems().setAll(data)).execute();
One can see that in this fluent API the last call goes to the service invocation's execute() method. However, it is advised to execute service invocations in a central place within the application's user interface codebase. This makes it easier to register default error handlers and to provide feedback to the user regarding the status of the execution of a service invocation. Example 2 shows how this is done.
ui.execute(ServiceInvocation.create("Load data ...", () -> myService.loadData().execute())
.onSuccess(data -> listView.getItems().setAll(data)));
Various consumers can be registered with a service invocation before it gets executed. Some
of these consumers have a second version with the postfix "default" to their name, e.g. "onFailure" and
"onFailureDefault". The idea behind this is that an application might provide a central place
where service invocations are being executed (e.g. Window.execute(si) or Workbench.execute(si))
and wants to set "default" handlers in that location. At the same time each specific occurrence
of a service invocation might require its own / more specific handlers.
| Modifier and Type | Class and Description |
|---|---|
| public static interface | ServiceInvocation.
the result type T>A functional supplier interface used for providing the response object of a retrofit call. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: always trueImplements javafx. Marks the invocation as cancelled. |
| public static < the type of the response object T> ServiceInvocation | Returns: a service invocationthe name of this invocation name, ServiceInvocation.the supplier returning the service for invocation supplierCreates a new service invocation instance. |
| private void | |
| private void | |
| private void | |
| public ReadOnlyObjectProperty | exceptionProperty()
Implements javafx. Gets the ReadOnlyObjectProperty representing any exception which occurred. |
| public CompletableFuture | Returns: a completable future object usable for chainingExecutes the service invocation with the default executor. |
| public CompletableFuture | |
| private void | |
| public Throwable | getException()
Implements javafx. Indicates the exception which occurred while the Worker was running, if any. |
| public String | getMessage()
Implements javafx. Gets a message associated with the current state of this Worker. |
| public String | |
| private BiConsumer | |
| private BiConsumer | |
| private BiConsumer | |
| private BiConsumer | |
| public double | getProgress()
Implements javafx. Indicates the current progress of this Worker in terms of percent complete. |
| public Worker. | Returns: the state of the service invocation according to theWorker interfaceImplements javafx. Returns the worker state of the service invocation (running, succeeded, ...). |
| public String | getTitle()
Implements javafx. An optional title that should be associated with this Worker. |
| public double | getTotalWork()
Implements javafx. Indicates a maximum value for the |
| public T | getValue()
Implements javafx. Specifies the value, or result, of this Worker. |
| public double | getWorkDone()
Implements javafx. Indicates the current amount of work that has been completed. |
| public boolean | Returns: true or false depending on whether the invocation has been cancelled or notReturns true if the application has invoked the |
| public boolean | isRunning()
Implements javafx. True if the state is either SCHEDULED or RUNNING. |
| public boolean | Returns: true if the invocation will failReturns true if the service invocation will intentionally fail (see also |
| public ReadOnlyStringProperty | messageProperty()
Implements javafx. Gets the ReadOnlyStringProperty representing the message. |
| public ServiceInvocation | Returns: the service invocationthe "on any status code" handler. onAnyStatusCode)A consumer that will be invoked when the backend service invocation was not successful. |
| public ServiceInvocation | Returns: the service invocationthe "on any status code default" handler. onAnyStatusCodeDefault)A consumer that will be invoked when the backend service invocation was not successful. |
| public ServiceInvocation | Returns: the service invocationthe consumer onException)A consumer that will be invoked in case of an exception during the execution of the service invocation. |
| public ServiceInvocation | Returns: the service invocationthe consumer onExceptionDefault)A default consumer that will be invoked in case of an exception during the execution of the service invocation. |
| public ServiceInvocation | Returns: the service invocationthe "on failure" handler. onFailure)A consumer that will be invoked when the backend service invocation was not successful. |
| public ServiceInvocation | Returns: the service invocationthe "on failure default" handler. onFailureDefault)A default consumer that will be invoked when the backend service invocation was not successful. |
| public ServiceInvocation | Returns: the service invocationthe "on failure detailed" handler. onFailureDetailed)A consumer that will be invoked when the backend service invocation was not successful. |
| public ServiceInvocation | Returns: the service invocationthe "on failure detailed default" handler. onFailureDetailedDefault)A default consumer that will be invoked when the backend service invocation was not successful. |
| public ServiceInvocation | |
| public ServiceInvocation | Returns: the service invocationthe runnable onFinallyDefault)A runnable that will be invoked after the service invocation has completed. |
| public ServiceInvocation | |
| public ServiceInvocation | Returns: the service invocationthe "on start default" handler. onStartDefault)A consumer that will be invoked first when the |
| public ServiceInvocation | Returns: the service invocationthe status code for which the consumer will be registered code, BiConsumer<String, String> the "on status code" handler. onStatusCode)A consumer that will be invoked when the backend returns the given HTTP status code. |
| public ServiceInvocation | Returns: the service invocationthe status code for which the consumer will be registered code, BiConsumer<String, String> the "on status code" handler. onStatusCodeDefault)A default consumer that will be invoked when the backend returns the given HTTP status code. |
| public ServiceInvocation | |
| public ServiceInvocation | Returns: the service invocationthe "on success detailed" handler. onSuccessDetailed)A consumer that will be invoked when the backend service invocation was successful. |
| public ReadOnlyDoubleProperty | progressProperty()
Implements javafx. Gets the ReadOnlyDoubleProperty representing the progress. |
| private void | |
| public ReadOnlyBooleanProperty | runningProperty()
Implements javafx. Gets the ReadOnlyBooleanProperty representing whether the Worker is running. |
| public ReadOnlyObjectProperty | Returns: the state propertyImplements javafx. Returns a read-only property for observing the state of the service invocation. |
| private void | |
| public ReadOnlyStringProperty | titleProperty()
Implements javafx. Gets the ReadOnlyStringProperty representing the title. |
| public ReadOnlyDoubleProperty | totalWorkProperty()
Implements javafx. Gets the ReadOnlyDoubleProperty representing the maximum amount of work that needs to be done. |
| public ReadOnlyObjectProperty | valueProperty()
Implements javafx. Gets the ReadOnlyObjectProperty representing the value. |
| public ServiceInvocation | Returns: the service invocationthe delay in milliseconds delay)Introduces an artificial delay for the invocation. |
| public ServiceInvocation | Returns: the service invocationenables / disables the failure failure)An easy way to explicitly make the service invocation fail in order to test the handling of failures by the application. |
| public ReadOnlyDoubleProperty | workDoneProperty()
Implements javafx. Gets the ReadOnlyDoubleProperty representing the current progress. |