Adding endpoints to the server

As covered in Chapter 25, 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 ...

Get Java 9: Building Robust Modular Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.