dev@jsr311.java.net

RE: Issue 1: Adding additional conneg metadata to _at_Produce/ConsumeXXX

From: Jerome Louvel <jerome.louvel_at_noelios.com>
Date: Sat, 16 Jun 2007 18:00:20 +0200

Hi Paul,

> > I think we could go further we automatically finding what
> is the best
> > representation among all acceptable ones, based on client
> preferences and
> > without requiring the developer to do anything else beside
> exposing its
> > available representations.
>
> Could you describe what you have in mind in more detail?

I guess the best for you is to have a closer look at the Restlet's Resource
class to see how we achieve transparent content negotiation:
http://www.restlet.org/documentation/1.0/api/org/restlet/resource/Resource.h
tml
http://www.restlet.org/documentation/1.0/api/org/restlet/data/Conditions.htm
l

> For the cases where what is acceptable cannot be determined
> statically
> via annotations are you proposing something similar to Restlet, which
> IIUC has a two stage method calling process? (Call a method
> to get the
> list of variants, then call the HTTP method with the selected
> variant.)

Exactly, but in our case, the second stage could be automated using the
Object to Representation conversion service.

> Assuming you are thinking along the lines of the Restlet
> design and that
> i have understood things correctly... the developer still has
> to perform
> an if/else on the selected variant to know which one has been
> selected
> by the runtime, and would still have to return some actual content.

Yes and no, because the actual content would be the Java object returned by
the tagged method.

To summarize: Restlet's Resource has a getVariants() method and a
getRepresentation(Variant) one. JSR-311 could have several GET-annotated
methods that would each represent an available representation (like toXml(),
getInputStream(), getContent(), etc.). The Variant class would be replaced
by metadata annotations.

[...]

Best regards,
Jerome