users@jersey.java.net

Re: [Jersey] Jersey's (experimental) approach to support hypermedia constraint

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Wed, 10 Feb 2010 10:03:21 -0500

On Feb 10, 2010, at 6:00 AM, Jan Algermissen wrote:
>
> I think there are different issues that need to be discussed separately:
>
> 1) What is the best way for a framework to support the
> server side developer in the task of adding links to
> the served representations?
> In my experience it is often hard to separate the
> creation of a domain object's representation from
> the addition of links in order to adhere to good
> programming practice. Usually I eventually have
> to copy/paste some code (which I hate).
>
> In part this is a result from links being part
> of the representations and sometimes also
> being placed in headers.
>
> Framework support tp ease thsese issues would be
> a good thing. But it would be purely server-side.
>
One of the things I'm keen to tackle in a follow-on JSR is support for declarative hyperlinking in representations. To give a flavor of the kind of thing I'd like to see possible in beans returned from resource methods:

// extracts URI template from resource class and fills in any template vars
// using the values of properties of the representation bean
@Link(resource=SomeResource.class)
private URI self;

// creates a URI from a template using embedded EL expressions
@Link(template="type/${type}")
private URI self;

We'll need to experiment with this a bit to get the right level of support and ease-of-use.

Marc.