users@jsr311.java.net

Re: JSR311: Re: Some comments to JSR 311

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Tue, 08 Jan 2008 11:12:53 -0500

On Jan 8, 2008, at 10:52 AM, Bill Burke wrote:
>
> I extremely disagree. Same Path, different resources, different
> MediaTypes is definately needed. You mean to tell me that I'm going
> to bloat each resource class to support all the media formats I
> want? This just isn't good design guys...
>
> I've already run into this issue in the prototype application I'm
> writing which is why I modified my JSR-311 implementation to support
> same path, different resources/different media types.
>
I think it depends on where you intend to put the serialization/
deserialization logic. Using MessageBodyReaders and MessageBodyWriters
you can have the same datatype being serialized to/from a variety of
formats while only using a single resource class. E.g.:

@Path("foo")
public class FooResource {

   @GET
   FooData getData() {...}
}

FooData is the Java bean you work with in your code and is the only
type understood directly by the resource. You can then have
MessageBodyWriters for a variety or formats without duplicating the
resource logic in additional resource classes.

Marc.

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