users@jersey.java.net

Re: [Jersey] Reverse Lookup

From: Frédéric Bouquet <bouquet.frederic_at_gmail.com>
Date: Fri, 28 May 2010 14:46:22 +0200

> Hi,

Hi,

> I am new to Jersey and try to generically use it in combination with
> Hibernate and XStream. When I send an resource object over the wire I use
> XStream for serialization and when this resource object contains references
> to other resource objects, I replace them with the resource URI instead of
> serializing them. This works quite good with the help of the UriBuilder
> (e.g. UriBuilder.fromResource(type).path(type,
> "getById").build(id).toString()).
>
> However – and that’s my question – how can I get the resource class back
> from the URI (e.g. /cars/123). Jersey does it once for the containing
> resource when the REST call hits it, but then I am on my own while
> deserializing the content. I must take an URI that I have built with the
> help of the UriBuilder and get the original resource class back. Does
> anybody know how to do this lookup from URI to resource class?

I'm not really sure to understand your needs but you may get the
resource from the body of the response.

When sharing a resource, you can send a Response and attach the object
(or a kind of mapping in xml/json/...) to the requester. In fact,
returning something built with :
Response.created(uri).type(MediaType).entity(yourobject).build() ?


> Thanks in advance,

Yw,
Hope it helps

> Vedran

Fred