users@jersey.java.net

Re: [Jersey] _at_ImplicitProduces and priorities <was> Re: [Jersey] prioritising HTML representations in web applications when using implicit or explicit views

From: James Strachan <james.strachan_at_gmail.com>
Date: Wed, 4 Feb 2009 17:45:53 +0000

2009/2/4 Paul Sandoz <Paul.Sandoz_at_sun.com>:
>
> On Jan 28, 2009, at 11:22 AM, James Strachan wrote:
>
>> 2009/1/28 Paul Sandoz <Paul.Sandoz_at_sun.com>:
>>>
>>> On Jan 28, 2009, at 10:38 AM, James Strachan wrote:
>>>
>>>> 2009/1/28 Paul Sandoz <Paul.Sandoz_at_sun.com>:
>>>>>
>>>>> On Jan 28, 2009, at 12:47 AM, James Strachan wrote:
>>>>>
>>>>>> 2009/1/27 James Strachan <james.strachan_at_gmail.com>:
>>>>>>>
>>>>>>> Awesome stuff Paul, many thanks! Taking it for a spin now...
>>>>>>
>>>>>> It works like a charm! Great stuff Paul!
>>>>>>
>>>>>
>>>>> Great. I am still not sure about the prioritization aspect of media
>>>>> types
>>>>> declared with @ImplicitProduces, it seems a hack that might be hard to
>>>>> remove when priorities are supported, or not be of the desirable
>>>>> behavior
>>>>> for some. It would be more consistent if @ImplicitProduces has the same
>>>>> order semantics as @Produces.
>>>>
>>>> Yeah.
>>>>
>>>> I wonder if we could just add support for priorities in the MIME types
>>>> for now?
>>>
>>> For @Produces that will require more work :-) I do not have time to
>>> investigate and implement in time for the 1.0.2 release with all the
>>> other
>>> things that need to be done.
>>
>> OK :)
>>
>> Would you have time to just support the priorities/quality for
>> @ImplicitProduces for 1.02?
>
> Contrary to my pessimism i managed to fine time.
>
> This is now supported in the trunk, including comma separated values.
>
> You need to specify the priority as a quality source using the "qs"
> parameter name.
>
> For example:
>
> @Path("/")
> @Singleton
> @ImplicitProduces("text/html;qs=5")
> @XmlRootElement
> @XmlAccessorType(XmlAccessType.FIELD)
> public class Bookstore { ... }

Its much less essential, but supporting the nicer new MIME strings on
@Produces would be great too - so you can use a single constant in
your code to refer to a set of MIME types (e.g. application/xml,
text/xml and application/json for example) to avoid having to cut and
paste a String[] expression in each method using the @Produces
annotation.

I've raised an issue for this so we don't forget - but its more a case
of making things more consistent and DRY, so way less important than
support in @ImplicitProduces :)
https://jersey.dev.java.net/issues/show_bug.cgi?id=202


-- 
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://fusesource.com/