Hi,
Our Jersey-based services need to consume requests from our clients .
Unfortunately, we have no control over what content type our clients may
use. Most of the time our clients may send out requests in JSON format
without specifying any content type, and sometimes text/plain may be used.
In that case, what's the best way of still supporting JAXB-JSON binding. For
example, how can I bind JSON message to a JavaBean object of type MyDataBean
as below?
@POST
@Consumes({MediaType.APPLICATION_OCTET_STREAM, MediaType.TEXT_PLAIN})
public Response process(MyDataBean bean){
....
}
I thought about creating my own MessageBodyReader implementation, but that
will duplicate logics in JSONRootElementProvider. I won't be able to extend
JSONRootElementProvider either because its constructors are package-private.
Should I use a JSONRootElementProvider as a delegate to my own
MessageBodyReader implementation? If so, how and where can I grab an
instance of JSONRootElementProvider? Or any better ways?
Thanks a lot,