August 2019
Intermediate to advanced
256 pages
6h 43m
English
MP-RC supports asynchronous method invocations. A client interface method is asynchronous when the return type of the method is of the java.util.concurrent.CompletionStage<?> type. An alternative version, called WorldClockApiAsync.java, of the WorldClockApi interface that declares an asynchronous method is as follows:
import java.util.concurrent.CompletionStage;import javax.ws.rs.GET;import javax.ws.rs.Path;import javax.ws.rs.PathParam;import javax.ws.rs.Produces;import javax.ws.rs.core.MediaType;@Path("/api/json")public interface WorldClockApiAsync { String BASE_URL = "http://worldclockapi.com/api/json"; @GET @Path("/utc/now") @Produces(MediaType.APPLICATION_JSON) CompletionStage<Now> utc(); @GET @Path("{tz}/now") @Produces(MediaType.APPLICATION_JSON) ...Read now
Unlock full access