Hi Moises,
that would be an option, yes, but it’s too complex and burns a lot more cycles than necessary. I just look for something that undoes what UriBuilder does.
Example: If UriBuilder.fromResource(User.class) adds a path segment to an URI that is something like “/users” and I put this as a string in my serialized resource and get it back later with a PUT/POST, I extract the URI string and want to call something that maps “/user” back to User.class. That’s what I look for. The REST container in Jersey can do that and does it automatically for the resource that is e.g. PUT/POSTed, but inside the serialized object I have URI references that I created with the UriBuilder before (or someone else who wanted to alter them) and these I want to turn again into objects and therefore I need the class. I could do what you proposed, but I look for something more simple – just the reverse operation of UriBuilder.fromResource().
Is there something like this in Jersey?
Regards,
Vedran
Von: Moises Lejter [mailto:moilejter_at_gmail.com]
Gesendet: Freitag, 28. Mai 2010 16:39
An: users_at_jersey.dev.java.net
Cc: users_at_jersey.dev.java.net
Betreff: Re: [Jersey] Reverse Lookup
I believe that you would just take the embedded URI and just issue it as a follow-up RESTful request ...
Moises
Sent from my iPhone
On May 28, 2010, at 5:55 AM, "Lerenc, Vedran" <vedran.lerenc_at_sap.com<mailto:vedran.lerenc_at_sap.com>> wrote:
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?
Thanks in advance,
Vedran