Java Reference
In-Depth Information
We can use the new CompletableFuture class from Java 8 to be notified about the
completion of a request:
CompletableFuture.<Collection<SeatDto>> supplyAsync(() -> {
try {
return future.get();
} catch (Exception e) {
throw new IllegalArgumentException(e);
}).thenAccept(seats -> seats.forEach(System.out::println));
After receiving the data, we simply print it out. Another option is to simply create an In-
vocationCallback class and pass it as a second argument to the get method.
Compiling our ticket example
Our sample can reside in a separate Maven module or you can leave it with the server
content (although it is not a good practice). In order to compile our client project with the
REST web service, we need to import the JAX-RS API that is included in the application
server libraries. We will need the following dependencies in our standalone application:
. . .
<version> ${version.resteasy-client}</version>
<version> ${version.resteasy-client}</version>
Search WWH ::

Custom Search