-
Notifications
You must be signed in to change notification settings - Fork 0
03.Entity Provider
Entity provider supplies mapping services between representations and their associated java types.
MessageBodyReader maps an http request entity body to method parameters.
MessageBodyWriter maps the returned object to the http response entity body.
In our example, we are creating the entity providers to support the custom MIME type "application/csv".
CSVMessageBodyReaderWriter.java
@Provider: makes the entity providers to be discoverable by the JAX-RS during runtime.
Optionally, these entity providers can also be registered manually to the application configuration for the same purpose.
The basic steps to writer custom entity provider
- Annotate the class with @Provider
- Implement either or both MessageBodyReader and MessageBodyWriter
Sample rest end point:
curl -H "Content-type:application/csv" -X GET http://localhost:8080/moviedirectory/rest/directory/
This example is taken from the book RESTful Java Web Services - Third Edition