We are actually mapping the media types with the uri suffix's.
Map<String, MediaType> type = config.getMediaTypeMappings();
And i have a resource which @Produces "application/xml".
Now, my requirement to receive the response in application/xml format from server for the uri's ending with suffix myhost.com/key.json
Since i have mapped the suffix's with media types as specified above which is always producing the JSON in this case.
Also, i have provided application/xml in the Accepts param in request header but didn't work.
I can't turn off the mediatype mapping as most of the resources need to produce application/json & application based on suffixes. But few resources i need to bypass the mediatype mapping for the uri suffixes ending with .json.
I assume the mapping is static (does not change at runtime). Then you can either override the media type in a pre-matching (!) filter (otherwise it is simply too late), or you can simply get rid of the filter and just use two @GET methods having distinct @Produces annotations and distinct @Path("key.json) annotations (Jersey will do the rest).