users@jsr311.java.net

Re: sub resource locators & generating urls

From: Jo Størset <jo.storset_at_usit.uio.no>
Date: Tue, 8 Jul 2008 18:36:49 +0200

Den 8. juli. 2008 kl. 16.49 skrev Marc Hadley:

> On Jul 8, 2008, at 3:44 PM, Jo Størset wrote:
>>> Being able to root the same resource class in multiple places is
>>> useful, e.g. a Customer resource could be available at:
>>>
>>> /customers/{id}
>>> /orders/{id}/customer/{id}
>>> /invoices/{id}/customer/{id}
>>
>>
>> But you would want the same way of instantiating a particular
>> customer for all these places (it's the same resource). And since
>> the sub resource path parameter is the same for these three cases,
>> why not put the @Path("{id}") on the customer object and let the
>> framework instantiate it, instead of duplicating the same logic
>> under all three parent resources?
>>
> You need the URI template on the sub resource locator method in
> order to decide which sub-resource method to call.

Guess I can't argue with that :) I guess I just have to work around
the limitations, and see where it brings me (and maybe take a closer
look at the wadl generation in jersey)

Jo