Skip to main content

Custom JAX-RS Providers

The custom ExceptionMapper demonstrated in the previous section is a custom JAX-RS provider. Custom MessageBodyReader, MessageBodyWriter and ExceptionMapper providers are most often used.

Custom MessageBodyReader and/or MessageBodyWriter is needed when the JAX-RS runtime needs to read the request messages which has the format not understood or mapped to/from Java classes in a way not supported by by its default readers and writers. Writing a custom reader and writer is not a complex process. For example, a custom MessageBodyReader should be able to answer if it supports reading a message with given MediaType into an object instance of some specific type; if the response is yes then the runtime will ask the provider to read the message from the given input stream.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!