users@jersey.java.net

Re: Generating urls and controlling rendering/serialization

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 04 Mar 2008 15:12:00 +0100

On Mar 4, 2008, at 1:55 AM, Jo Størset wrote:

>
> Den 3. mars. 2008 kl. 19.13 skrev Marc Hadley:
>
>>> Is that the kind of thing you are looking for ?
>
> Yes, I was thinking that this is exactly the kind of support that
> would be needed to make rest development clean and simple. But
> since I'm new to this, I was kind of hoping others would have a
> better understanding than me :)
>

This is the one area where i think we are lacking a good approach in
311 and Jersey, so your thoughts and experience on the matter are
helping us a lot. When i have presented on JAX-RS/Jersey i highlight
that connectedness is the one area where i think more novel work is
required.


> In our own resource centric web solution, we have the notion of
> services applied to resources in a content repository. These
> services, like jersey resources, are used both for mapping requests
> to funcionality and for generating urls to the service on specific
> resources (service.createLink(Resource resource) more or less). In
> this scenario all resources have a path (id), which I believe
> corresponds to your use of the @id and @ResourceClass annotations.
> Wouldn't this be very helpful for building clean, maintainable rest
> style apps?
>

I agree this approach looks interesting. I think it requires some
experimental prototyping, the nice thing is this seems reasonably
separate from the other aspects of the 311 API, so could evolve
independently.

My preference would be probably not to annotate a model class with
the resource class but just to identify JavaBean properties
associated with bits of the URI (template variables?). This means one
could use a resource class or a URI template and thus could be used
in different contexts. Another approach instead of using annotations
is to have a mapping class that could inform about the properties on
'n' number of beans (if code is generated this is potentially not a
bad thing).


> On JPA, I don't use JPA myself, and I don't know how clean it would
> be to use jpa @id annotations in a generalized way. But i guess it
> would be doable?
>

It would probably work if a convention is agreed to. Note that the
RESTful Web services plugin for NetBeans maps JPA entity beans to
JAXB beans and converts identifiers in the former to URIs in the
latter, i think we can learn from that for a more automated approach.


> I was also thinking about the possibility of rest annotating the
> model resources directly (since the annotations themselves
> constitutes a level above the resources), instead of making an
> explicit resource layer. But I guess this would be quite intrusive
> to the current way of doing layering of apps, since the access
> methods don't really belong in the resource.

Yes, a merging of distinct layers makes things hard to reuse.


> Maybe I should be looking to the seam way of building apps, since
> it seems geared towards this type of merging of the web and
> resource layer. Does anybody else have any ideas in this regard?
>

I don't know much about Seam but my understanding is the presentation
tier and business tier are merged into one component model, and it is
not necessarily about merging a data model and network access to that
data model into one class.

Paul.