users@jersey.java.net

Re: [Jersey] Mixing templates with JAXB

From: Alex Vollmer <alex.vollmer_at_gmail.com>
Date: Mon, 9 Mar 2009 13:21:08 -0700

On Mar 9, 2009, at Mar 9, 7:58 AM, Paul Sandoz wrote:

> You can do things explicitly:
>
> @Produces("application/xml")
> public Bean getBean() {
> ...
> }
>
> @Produces("text/html")
> public Viewable getViewable() {
> return new Viewable("index", this);
> }
>
>
> If you want to above behavior implicitly, then if you are using
> Jersey 1.0.2, you can do:
>
>
> @ImplicitProduces("text/html")
> public class MyResource {
> @Produces("application/xml")
> public Bean getBean() {
> ...
> }
> }
>
> Paul.

What would this look like if one were to tweak the bookstore example?
Sorry, but I'm still a little unclear on exactly how to do this. Do I
need a separate method for each content-type? If so, does each one
repeat the same HTTP method and path annotations, but specifies a
different @Produces annotation?

I've added JAXB annotations to the Item type, but haven't been able to
get different results based on different Accept headers (using the
curl command-line tool for testing). Any help is appreciated.

Thanks!

----
Musings & Notes
http://blog.livollmers.net