excalibur-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Burrell Donkin <robertburrelldon...@gmail.com>
Subject Re: Playing Better With Dependency Injection
Date Wed, 19 Aug 2009 10:40:46 GMT
On Wed, Aug 12, 2009 at 11:43 AM, J Aaron Farr<farra@apache.org> wrote:
> On Tue 11 Aug 2009 22:36, Leo Simons <mail@leosimons.com> wrote:
>> On Tue, Aug 11, 2009 at 10:44 AM, Robert Burrell
>> Donkin<robertburrelldonkin@gmail.com> wrote:
>>> avalon is an IoC container but is mainly tooled for composition using
>>> the Service Locator pattern (Servicable, ServiceManager). these days,
>>> dependency injection (whether through setters or constructors) is much
>>> more popular. so, i think we should add setters, getters and
>>> constructors so that Servicable components can also play well in DI
>>> containers.
>>> opinions?
>>> objections?
>> The avalon lifecycle interfaces have this nice container-provided
>> guarantee that after the last few of them have been called, you know
>> your component is in a fully initialized state, fully aware of its
>> surroundings, and that those surroundings won't change after that
>> (unless you implement Re* which is again a set of specific contracts).
>> While I think its quite alright to add support for dependency
>> injection, I think it is important to keep this
>> guaranteed-to-be-initialized-at-an-obvious-point-in-time contract
>> intact. That's trivially true if you use constructor DI, but not so
>> much so if you add setters, so I'd rather not see any setter
>> injection.
> I agree with Leo on this one.  If there's a way we can support running
> Avalon services in setter-style DI containers, then that's great.  But
> I'd also want to make sure that all the promises we've made about
> lifecycle support are maintained.

IMHO lifecycle guarantees need to be enforced by the container and are
independent of the injection strategy

setter injections (and dynamic service locators) typically need to
perform lifecycle management, so these just need to be bridged

for example, the avalon-spring bridge from jamesland adapts spring
lifecycle events into avalon ones. so, even though the spring
injection is setter based, the dependent components will be injected
before the appropriate avalon lifecycle methods are called.

i would expect that the dynamic approach to service provision adopted
by OSGi would mean that an OSGi enabled avalon service would need to
call appropriate lifecycle methods to manage services coming and

- robert

To unsubscribe, e-mail: dev-unsubscribe@excalibur.apache.org
For additional commands, e-mail: dev-help@excalibur.apache.org

View raw message