Hi all,

Recently the topic of supporting autowiring of constructor parameters
(IoC type 3) has come up a few times.  I've taken a stab at
implementing this in the BuilderFactory and it turns out to be rather
easy.  A few considerations and notes:

- The constructor autowiring would only kick in if there are no
explicitly declared constructor parameters.  Otherwise it could both
prove complex to implement _and_ use.
- All the constructor parameters have to be declared as interfaces.
- If there are multiple constructors present BuilderFactory would
chose the one with the highest number of parameters (greedy).

Does this sound reasonable?  I still have a few open issues I'd like to discuss:

- Should there be an attribute on <construct> to explicitly enable or
disable this constructor autowiring (e.g. "autowire-constructor")? 
IMO the BuilderFactory should be default autowire the constructor if
there are no declared constructor parameters.  This should work well
for both the setter based _and_ constructor based dependency injection
camps.
- Should BuilderFactory report an error if there are multiple
constructors which seem equally adequate (same number of parameters
and a matching service for each)?

--knut

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to