users@jsr311.java.net

Re: Path annotations for class resources

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 28 Feb 2008 13:18:30 +0100

Bill Burke wrote:
>
>
> Sergey Beryozkin wrote:
>> Thanks...
>>
>> here's another question.
>>
>> If a @Path annotation for a root resource contains template variables
>> then how are they applied to diferrent resource methods ?
>> For ex :
>>
>> @Path("/foo/{id1}")
>> class Foo {
>>
>> @GET
>> public Bar getBar(@PathParam String id1 <mailto:id1_at_PathParam>) {
>> }
>>
>> @GET
>> Path("bar")
>> public Bar getSubresourceMethodBar(@PathParam String id1
>> <mailto:id1_at_PathParam>) {
>> }
>> }
>>
>
> I believe id1 is not available in Bar. In other words, path params are
> scoped to the resource they are defined in.
>

The intention is to make it available as the 'getSubresourceMethodBar'
method is a sub-resource method of the (root) resource class Foo i.e.
one can consider the scope to be the "resource class", since this models
a set of Web resources (those matching the template and sub-resources).

So the request URI path:

   /foo/1/bar

would match the root resource class Foo and the request would get
dispatched to the method 'getSubresourceMethodBar' with the template
value of the template variable "id1" set to "1". The representation
returned from 'getSubresourceMethodBar' may well require that is knows
what the template value for the variable "id1" is before it can return
an appropriate representation.

IMO i think way too restrictive to limit the scope of the @PathParam,
thus it should be possible to access the value of any template variable
that has been extracted from the left-hand side of the request URI path
that has been matched. The most recent template variable should take
precedence over previous template variables of the same name.

Paul.

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109