users@jsr311.java.net

Re: sub resource locators & generating urls

From: Matt Brozowski <brozow_at_opennms.org>
Date: Tue, 8 Jul 2008 11:57:16 -0400

On Tue, Jul 8, 2008 at 8:02 AM, Marc Hadley <Marc.Hadley_at_sun.com> wrote:

> On Jul 8, 2008, at 1:46 PM, Jo Størset wrote:
>
>>
>> 1) If I wanted to have a Keywords and a Keyword class I can
>>>> - use a sub resource locator, but then I have to give up all support
>>>> for DI or 'pollute' the parent with the child's dependencies?
>>>> - duplicate the path in the two classes?
>>>>
>>>> How should I model this effectively?
>>>>
>>> Yes, that is right. Dependencies are only injeced in classes
>>> instantieated by the runtime. Marc answered a reason I think, but I didn't
>>> know the reason yet. I also think it is useful to allow this injection.
>>>
>>
>> I guess it simply is a necessary trade off that had to be made?
>>
>> The main issue is that the application is in charge of the returned
> object's lifecycle so its hard to know when its desirable to inject and when
> not.


I think it would be possible to return some kind of
'DependencyInjectionContext' that would allow you to ask it for an instance
of the object that was properly dependency injected. Sort of like springs
getBean() methods. Does that seem like a possibility?

Matt