Custom JAX-RS Providers - 6.3

Talend ESB Service Developer Guide

Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
Design and Development
Installation and Upgrade
Talend ESB

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.