Re: ProduceMime and ConsumeMime

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Mon, 09 Apr 2007 13:22:12 -0400

On Apr 9, 2007, at 11:46 AM, Julian Reschke wrote:

> Marc Hadley schrieb:
>> Right. The thinking is that if you have a lot of methods with
>> common media type characteristics you can put the annotations at
>> the class level and then only override them for individual methods
>> that differ. If you only have a couple of methods in total and
>> they are different you can just put the annotations at the method
>> level since class level annotations won't save anything.
> OK, thanks for the clarification.
> Do you have a real-world use case in mind where a resource would
> actually accept many methods with the same types of payloads? Right
> now, I can't think of any...
You might want a bunch of POST methods that all return different
media types. That way you can leave the content negotiation to the
JSR 311 runtime which will call the correct method based on the value
of the Accept header in the request, e.g.:

public class FormProcessor {

   public Source postFormAsXml(FormURLEncodedProperties data) {

   public Source postFormAsHtml(FormURLEncodedProperties data) {

   public JSONObject postFormAsJson(FormURLEncodedProperties data) {


Marc Hadley <marc.hadley at>
CTO Office, Sun Microsystems.