Skip to main content

[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@...>
  • To: jsr339-experts@...
  • Subject: [jsr339-experts] Re: [jax-rs-spec users] Re: Injecting a sub-resource method path parameter into a resource field - legal or not?
  • Date: Fri, 24 Feb 2012 08:56:20 -0500


On Feb 23, 2012, at 11:22 AM, Sergey Beryozkin wrote:

> On 23/02/12 16:06, Marek Potociar wrote:
>> Yes it is there. But this particular use case is not explicitly covered. 
>> IOW it's ambiguous.
> 
> I'm not sure it is. @PathParam, @QueryParam and similar are scoped by 
> request. In case of getFoo() no such capturedvalue exists so it is null.

 Right, this isn't different from a @*Param without a default value that 
isn't specified. By adding a single sentence to the Javadoc or spec, this 
case should be easily clarified IMO.

-- Santiago

> 
> It's the same as
> Path("{id1}")
> getFoo(@PathParam("id1") String id1, @PathParam("id2") String id2)
> 
> id2 is null...Thus in
> 
> 
> @PathParam("id2") String id2;
> 
> Path("{id1}")
> getFoo(@PathParam("id1") String id1);
> 
> id2 is null
> 
> Cheers, Sergey
> 
>
>> Marek
>
>> On 02/23/2012 02:49 PM, Sergey Beryozkin wrote:
>>> btw, I'm not sure it is even in the spec now, support for injecting 
>>> JAX-RS parameter values as properties (via fields or
>>> setters), I recall it was in 0.8 or similar and at some stage I also 
>>> remember seeing the advice about the thread safety
>>> too; as it's impossible to inject a proxy for 'int'
>>> 
>>> Sergey
>>> 
>>> On 23/02/12 13:46, Sergey Beryozkin wrote:
>>>> On 23/02/12 13:37, 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?
>>>> 
>>>> 'null' - because no "id" template var has been captured in context of
>>>> getFoo(), this is why this style is limited to the per-request root
>>>> resources only, not thread-safe otherwise
>>>> 
>>>> Cheers, Sergey
>>>> 
>>>>> 
>>>>> 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
>>>> 
>>>> 



[jsr339-experts] Injecting a sub-resource method path parameter into a resource field - legal or not?

Marek Potociar 02/23/2012

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

Sergey Beryozkin 02/23/2012

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

Marek Potociar 02/23/2012

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

Sergey Beryozkin 02/23/2012

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

Sergey Beryozkin 02/23/2012

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

Marek Potociar 02/23/2012

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

Sergey Beryozkin 02/23/2012

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

Santiago Pericas-Geertsen 02/24/2012

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

Bill Burke 02/23/2012

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

Marek Potociar 02/23/2012

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

Bill Burke 02/23/2012
 
 
Close
loading
Please Confirm
Close