users@jersey.java.net

[Jersey] Re: Detecting selected variant/media type.

From: ymkm <andy_at_ymkm.com>
Date: Sun, 28 Aug 2011 16:48:58 -0700 (PDT)

I'm doing something like this (simplified to a fixed list of types in example
below) - would be keen to hear if there are better solutions - for example
if it is possible to access the list of supported types declared in the
@Produces annotation.



thanks

Andy



Jeff Adamson wrote:
>
> Hi,
> I have a quick question.
>
> Given a resource like
>
> private final String MEDIA_ZIP = "application/zip";
>> private final String MEDIA_TAR = "application/x-tar";
>> private final String MEDIA_TGZ = "application/x-gzip";
>>
>
>
> @GET
>> @Path("path")
>> @Produces({MEDIA_ZIP, MEDIA_TAR, MEDIA_TGZ})
>> public Response downloadArchive(@PathParam("path"))
>> throws Exception {
>
>
> How do i detect which of the produces variant is the
> request/most-preferred
> by the client? I have to write back a native stream (Apache Commons
> Compress ArchiveOutputStream) so my code needs to know which type it
> should
> be producing.
>
> Thanks
> --Jeff
>


--
View this message in context: http://jersey.576304.n2.nabble.com/Detecting-selected-variant-media-type-tp6729060p6735961.html
Sent from the Jersey mailing list archive at Nabble.com.