users@jersey.java.net

[Jersey] Jersey(2.10.4) Entity provider selection algorithm gives less priority to custom providers(MessageBodyWriter) making it not to be invoked

From: Shaswat <shaswat.dasgupta_at_gmail.com>
Date: Wed, 18 Feb 2015 02:27:21 -0700 (MST)

We have a custom MessageBodyWriter in our application that produces data of
Media type application/xml.As we know Jersey 2.x has an
algorithm(https://jersey.java.net/documentation/latest/message-body-workers.html#mbw.writer.selection.algorithm)
that chooses a suitable MBR from a list of internal and custom
MessageBodyWriters to persist entity into output buffer.The algorithm sorts
MBR is based upon Object type distance and media type distance.So our Custom
MBR is not getting invoked as we saw in the Jersey common code
(MessageBodyFactory.getMessageBodyWriter())that our Custom Writer is at the
below in the list and some other provider whose isWriteable() method returns
true getting invoked.

The question is how can we force Jersey to invoke custom MessageBodyWriters
??Should we try adding a custom media type(like application/vnd.xml) to
force it to call Custom types?




--
View this message in context: http://jersey.576304.n2.nabble.com/Jersey-2-10-4-Entity-provider-selection-algorithm-gives-less-priority-to-custom-providers-MessageBodd-tp7583127.html
Sent from the Jersey mailing list archive at Nabble.com.