users@jax-rs-spec.java.net

[jax-rs-spec users] [jsr339-experts] Re: Re: Back To DI in Subresources

From: Bill Burke <bburke_at_redhat.com>
Date: Tue, 17 Apr 2012 12:12:02 -0400

On 4/17/12 11:37 AM, Santiago Pericas-Geertsen wrote:
>
> On Apr 17, 2012, at 7:45 AM, Marek Potociar wrote:
>
>> There are 2 solutions that I've been thinking about:
>>
>> 1. introduce an injectable request-scoped ResourceContext with
>> methods like inject(Class<?> subresourceClass), inject(Object
>> subresource)
>> 2. update the spec to mandate field injection on the sub-resource
>> instances returned by sub-resource locator.
>>
>>
>> So far I am leaning towards #1 as it seems more flexible.
>>
>> Any thoughts on the above?
>
> Why not both? As you say, (1) is more flexible but (2) is quite convenient.
>

I don't see why you need #1 if you have #2. Things would be doubly
injected. Also, is there any issues with singletons vs. per-request
sub-resource instances? I can't think of any at the moment, so long as
injected things are proxied appropriately.

Bill

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com