users@jersey.java.net

Re: [Jersey] Support for declarative linking (server-side) [Was: Jersey's (experimental) approach to support hypermedia constraint]

From: Jan Algermissen <algermissen1971_at_mac.com>
Date: Wed, 10 Feb 2010 16:34:29 +0100

On Feb 10, 2010, at 4:03 PM, Marc Hadley wrote:

> 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.

Yes.

> 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

Yes, the information what resources there are that can be linked to (and how) is in the resource classes and their annotations. You mean exploiting that, yes?

> // 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.

Makes sense conceptually.

Just as a side note: What one needs to be aware of is that there is not a one to one relationship between domain (backend) objects and resources. Resources provide application state to clients, not only serialzed domain objects. The mapping is often pretty close, but then there might be additional links you want to put in there that cannot be taken from the domain.

Jan


>
> Marc.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>

-----------------------------------
 Jan Algermissen, Consultant
 NORD Software Consulting

 Mail: algermissen_at_acm.org
 Blog: http://www.nordsc.com/blog/
 Work: http://www.nordsc.com/
-----------------------------------