On 20/04/12 16:05, Santiago Pericas-Geertsen wrote:
>
> On Apr 19, 2012, at 5:01 AM, Sergey Beryozkin wrote:
>
>>>>
>>>
>>> Why not both? As you say, (1) is more flexible but (2) is quite convenient.
>>>
>>
>> I don't understand how the sub-resource injection can work at all.
>> Lets take an example where a root resource is a singleton.
>>
>> This root resource can return sub-resource instances. Such instances can be created at a per-request basis or may've been pre-allocated and are singletons too. Only the root resource knows the rules.
>>
>> How can the runtime make sure that the injection into sub-resources is thread-safe ?
>
> The spec already states that field/property injection is only guaranteed to work in the default per-request lifecycle, given that it is only lifecycle mandated by the spec.
>
The field injection of @Context-annotated properties (UriInfo, etc) is
always thread-safe, for singletons or per-request providers
> Back to your point, are you suggesting that the problem is significantly different from injecting into a field/property in singleton _root_ resource class? You must have concurrency issues there too.
>
I'm just reading the response from Marek and I wonder if I've completely
mis-interpreted the original proposal...Let me postpone answering here
for a bit...
Cheers, Sergey
> -- Santiago
>