I don't think you shouldn't do anything in your code... besides creating the proper "converter" to serialize your data.The whole idea about @produces is to automatically invoke wathever "converter" has been setup for a given mime-type without clunking your code with serialization logic.
> Date: Sun, 28 Aug 2011 16:48:58 -0700
> From: andy_at_ymkm.com
> To: users_at_jersey.dev.java.net
> Subject: [Jersey] Re: Detecting selected variant/media type.
>
> 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.