July 2017
Intermediate to advanced
466 pages
11h 24m
English
As covered in Chapter 9, Taking Notes with Monumentum, a JAX-RS resource lives in a POJO with certain annotations. To stub out our endpoint class, we can start with this:
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
protected class DeskDroidResource {
}
We will also need to register this class with JAX-RS, which we do with this line in startServer():
config.registerInstances(new DeskDroidResource());
Ordinarily, we would pass, say, DeskDroidResource.class, to the ResourceConfig constructor, like we did with JacksonFeature.class. We will be accessing Android resources, and to do that, we're going to need the Service's Context instance. There are a number of resources on the internet that will suggest ...
Read now
Unlock full access