users@jersey.java.net

Re: [Jersey] Bringing RESTful "connectedness" to my existing domain objects

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 10 Dec 2008 11:16:53 +0100

HI Bret, Craig,

On Dec 8, 2008, at 1:02 AM, Brett Dargan wrote:

> I'm not sure if we are quite talking about the same things,

Yes, i agree. It is about providing a solution to embedded links into
JAXB representations that link to further resources classes. And i
think it is compatible with the separate layers that Craig describes
i.e. transforming some data from somewhere with the @Path of a
resource class and a base URI to produce a link. One can do it
manually but it is error prone so having a way to automate this is
very useful. Another useful aspect could be to provide additional
attributes associated with links like the "rel" attribute, that can
provide meta-data on the link type.

I have no time at the moment to look in detail, sorry, the Devoxx
conference is taking most of the time this week, but i hope to think
about this more perhaps on the train journey back on the Friday or
next week.

Paul.


> so I've attached some code (very rough).
>
> My goal is to provide a sound api around some existing jaxb
> annotated objects.
> They currently represent our core messages used throughout multiple
> applications.
> They are not the same classes used for persistence, they are used by
> some existing web applications.
>
> The new services won't provide much html representations and if they
> do it will be limited to html fragments.
>
> The only thing I'm embedding about the view in my objects is the
> links to other Resources (and that is only because of the
> annotations, we could do this in an external file as well).
>
> My api shouldn't change too much, ;) how many times have we said
> that before.
>
> Given that jersey allows us to easily create multiple
> representations, but in order to fully "connect" my resources I
> can't see how I can achieve this without marking up my domain
> objects in some way as the marshalling is done via jersey on my
> domain objects.
>
> Especially when I may want fine-grained links, so a User may have
> Payments and one Representation of a UserResource may list the
> individual payment links, not just a link to a PaymentResource that
> identifies payments for that user. (actually i didn't do that in the
> sample)
>
> I've attached a diff that can be applied to the helloworld sample in
> jersey 1.0.1, to try it out
>
> i jersey-1.0.1/samples/helloworld
> patch -p0 < connectedness.patch
>
> run it up with mvn compile exec:java
> in another window run the ./go script to hit some urls (assuming you
> have curl).
>
> cheers,
> Brett.
> <connectedness-
> patch
> .txt
> >---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net