users@jersey.java.net

Choosing a Provider for a MediaType in Ambiguous Conditions

From: Stephen Duncan Jr <stephen.duncan_at_gmail.com>
Date: Mon, 6 Apr 2009 21:57:45 -0400

I'm prototyping some use of JAX-RS and JSON. I'm trying to use Jersey and
Jackson (http://jackson.codehaus.org/). I'd like to bring over a particular
issue I'm facing with this that I brought up on the Jackson user mailing
list:
http://archive.codehaus.org/lists/org.codehaus.jackson.user/msg/b20ce4ed0904061253w38bcaa0crccd0fff3803f3390@mail.gmail.com

To summarize: Jackson has a JAX-RS Provider implementation. However, since
Jackson can convert POJOs to JSON, it essentially registers itself to handle
any object where the media-type is application/json. What I want, however,
is the flexibility to still return or process JSON through alternate means
when it's appropriate: as StreamingOutput, as a String, or as some other
libraries JSON object model.

What's the best way to acheive this? In the post I linked to, I speculated
about some sort of delgating provider implementation. Is there some other
mechanism in JSR-311? Or in Jersey?

(As a side note: I'm currently using the jersey-spring integration to wire
things together and to register the Jackson provider, but I'm open to
alternate techniques if it solves this problem).

-- 
Stephen Duncan Jr
www.stephenduncanjr.com