users@jax-rs-spec.java.net

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

From: Adam Bien <abien_at_adam-bien.com>
Date: Tue, 17 Apr 2012 20:28:01 +0200

Hi Bill,

you are right #2 is even better. I misunderstood that. It means: I could create a sub-resource with "new" and return it. JAX-RS would care about @Inject, @Resource etc. injection into the manually created sub-resource.

But: support for #1 could be still interesting.

adam
On 17.04.2012, at 18:12, Bill Burke wrote:

>
>
> 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