jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] Re: [jax-rs-spec users] Re: Injecting a sub-resource method path parameter into a resource field - legal or not?

From: Santiago Pericas-Geertsen <Santiago.PericasGeertsen_at_oracle.com>
Date: Tue, 6 Mar 2012 10:43:46 -0500

Marek,

 I've included a similar example in the spec to explain this use case. Will commit changes later today.

-- Santiago

On Feb 23, 2012, at 8:37 AM, Marek Potociar wrote:

> To elaborate more, consider also the extended example:
>
> @Path("foo")
> public class FooResource {
> @PathParam("id") String id;
>
> @GET
> public String getFoo() {
> return id;
> }
>
> @GET
> @Path("bar/{id}")
> public String getBar() {
> return id;
> }
> }
>
> Should the above be legal? What should be returned for a GET "/foo" request?
>
> Marek
>
> On 02/23/2012 12:01 PM, Marek Potociar wrote:
>> Hello experts,
>>
>> we've received a bug report in Jersey about the following use case:
>>
>> @Path("foo")
>> public class FooResource {
>> @PathParam("id") String id;
>>
>> @GET
>> @Path("bar/{id}")
>> public String get() {
>> return id;
>> }
>> }
>>
>> My question is, given the "id" path template is defined on a sub-resource method, should the value still be injectable
>> into the resource field or not?
>>
>> IOW, with the example above, what should be a result of GET "/foo/bar/baz" request? Should it be "baz" or null ?
>>
>> Thanks,
>> Marek