Jackson as jax-rs provider?


Y. Richard Yang
 

Hi Kai, all,

I am taking a look at alto-northbound on how it parses the entity body. My early thought was that we would define new entity body providers to parse and serialize alto media types: https://jersey.java.net/documentation/latest/message-body-workers.html

In reading the current design (alto/alto-northbound/src/main/java/org/opendaylight/alto/northbound), I saw that we are parsing a string, e.g.,
    @Path("/filtered/networkmap/{id}")
    @POST
    @Consumes({ MediaType.ALTO_NETWORKMAP_FILTER})
    @Produces({ MediaType.ALTO_NETWORKMAP, MediaType.ALTO_ERROR})
    public Response retrieveFilteredNetworkMap(
            @PathParam("id") String id, String filterJSON) {
    ...
    NetworkMap.Filter filter = mapper.asNetworkMapFilter(filterJSON);
...

I am not an expert of jax-rs, and I am actually fine with parsing the body as a String. This seems to imply scanning the msg body twice: first to convert to a strng and the scan it, but the msg body is small anyway. 

My question is: how is the conversion from body to the string happened (https://jersey.java.net/documentation/latest/message-body-workers.html#providers-selection). Is the MessageBodyReader<T>/MessageBodyWriter<T> design considered ()?

Thanks!

Richard