On Mar 11, 2010, at 2:32 PM, Marc Hadley wrote:
>
>> e.g. if the @Link could just refer to the owner, then you could find
>> the getShipment() method on Widget and find its URI template from the
>> @Path annotation? e.g.
>>
>> class Shipment {
>> @Link(ownedBy="widget")
>> URI link;
>>
>> String shipmentId;
>> Widget widget;
>> }
>>
>> Then the URI template is only specified once - in the usual place -
>> and it can be deduced by looking for the method in the owner with a
>> @Path annotation which returns an object of the type Shipment? (For
>> the @Path URI template on Widget.getShipment() to be usable with
>> @Link
>> we'd need to use consistent naming of the 'shipmentId' parameter).
>>
>> You could argue that the owner could be deduced too (by analysing all
>> of the available resources and figuring out which resource is capable
>> of making a Shipment) - but you could possibly have a resource which
>> is available via multiple URIs maybe - so being explicit in this case
>> is not such a bad thing IMHO.
>>
> For the URI of the resource or its subresources then I think the $
> {UriInfo.requestUri} approach will get us most of the way. For
> linking back up the call stack then UriInfo also has the
> getMatchedURIs method so you can, e.g., pull out the URI of each
> resource in the call stack.
>
Jersey also exposes the "stack" of URI templates in ExtendedUriInfo
[1]. Is that something useful?
Paul.
[1]
https://jersey.dev.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/core/ExtendedUriInfo.html