August 2019
Intermediate to advanced
256 pages
6h 43m
English
MP-RC type-safe interfaces may be injected as CDI beans. The runtime must create a CDI bean for each interface annotated with @RegisterRestClient. A CDI client injects bean created will include a qualifier, @RestClient , to differentiate use as an MP-RC injection point. The following update to our WorldClockApi interface illustrates the use of the @RegisterRestClient annotation:
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;import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;@Path("/api/json")@RegisterRestClient()public interface WorldClockApi { static final String BASE_URL = "http://worldclockapi.com/api/json"; ...Read now
Unlock full access