Leos Bitto
2009-05-07 11:30:30 UTC
Hello,
I have an application which requires an IoC container to be run. Currently
it works with Spring Framework and I would like to try PicoContainer, too.
The application is designed to use both constructor and setter injection.
The constructor injection is used mainly for mandatory dependencies, while
the setters are used maily for optional dependencies - the compoments
usually can work without those optional dependencies, for example by having
a default value assigned to the appropriate fields directly in the source
code. I know that it could be rewritten to use only the constructors, but
then the configuration would get a bit messy, because the constructor
parameters do not have names (unlike the setters). Additionally, generating
tons of constructors for various combinations of optional dependencies is
not nice.
The requirement is to have the configuration in an XML file, therefore I
have tried to use PicoContainer Script 2.0.1 this way:
picoContainer = new DefaultPicoContainer(new CompositeInjection(new
ConstructorInjection(), new SetterInjection()));
final ClassLoader cL = Thread.currentThread().getContextClassLoader();
new
XMLContainerBuilder(cL.getResource(config),cL).populateContainer(picoContainer);
However, I am not able to rewrite the Spring XML file to the PicoContainer
Script XML file and I start getting the feeling that such mixed dependency
injection (constructor + optional setters) is not supportted by
PicoContainer. Could someone please prove me wrong?
Leos Bitto
I have an application which requires an IoC container to be run. Currently
it works with Spring Framework and I would like to try PicoContainer, too.
The application is designed to use both constructor and setter injection.
The constructor injection is used mainly for mandatory dependencies, while
the setters are used maily for optional dependencies - the compoments
usually can work without those optional dependencies, for example by having
a default value assigned to the appropriate fields directly in the source
code. I know that it could be rewritten to use only the constructors, but
then the configuration would get a bit messy, because the constructor
parameters do not have names (unlike the setters). Additionally, generating
tons of constructors for various combinations of optional dependencies is
not nice.
The requirement is to have the configuration in an XML file, therefore I
have tried to use PicoContainer Script 2.0.1 this way:
picoContainer = new DefaultPicoContainer(new CompositeInjection(new
ConstructorInjection(), new SetterInjection()));
final ClassLoader cL = Thread.currentThread().getContextClassLoader();
new
XMLContainerBuilder(cL.getResource(config),cL).populateContainer(picoContainer);
However, I am not able to rewrite the Spring XML file to the PicoContainer
Script XML file and I start getting the feeling that such mixed dependency
injection (constructor + optional setters) is not supportted by
PicoContainer. Could someone please prove me wrong?
Leos Bitto
--
View this message in context: http://www.nabble.com/Combined-constructor-and-setter-injection-tp23424827p23424827.html
Sent from the NanoContainer - PicoContainer - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
View this message in context: http://www.nabble.com/Combined-constructor-and-setter-injection-tp23424827p23424827.html
Sent from the NanoContainer - PicoContainer - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email