Andre Costa
2008-10-25 16:33:58 UTC
Hi,
... this is probably a silly question, please bear with the newbie ;-)
I'm trying to learn how to use PicoContainer for a presentation about IoC
and Dependency Injection frameworks I'm preparing, and so far I think I
understood the main points. However, I have one major doubt that's been
bugging me: is it possible to pass external objects to be used by a
container as parameters for the instantiation of another object?
Eg. considering the Juicer class on [
http://www.picocontainer.org/introduction.html], suppose I need to create a
Juicer with my own instance of a Peeler (eg. a modified clone of an
instance) instead of letting the container create a new one for me, or use a
cached one. It would be something like:
pico.getComponent(Juicer.class, myPeelerInstance);
as if this by this I could tell the container that it should use the
received object as one of the parameters for the construction of Juicer
instead of trying itself to create a Peeler.
Is this possible anyway? Am I going the wrong way here?
This question came to mind when I thought of one scenario that happens in
one of our applications, in which ObjectA that receives ObjectB and
manipulates (changes) it sometimes (depending on the situation) receives a
clone of an instance of ObjectB so that changes can be discarded if desired
after the manipulation ends.
I hope I made myself clear, please let me know if any further details are
needed.
Regards,
Andre
... this is probably a silly question, please bear with the newbie ;-)
I'm trying to learn how to use PicoContainer for a presentation about IoC
and Dependency Injection frameworks I'm preparing, and so far I think I
understood the main points. However, I have one major doubt that's been
bugging me: is it possible to pass external objects to be used by a
container as parameters for the instantiation of another object?
Eg. considering the Juicer class on [
http://www.picocontainer.org/introduction.html], suppose I need to create a
Juicer with my own instance of a Peeler (eg. a modified clone of an
instance) instead of letting the container create a new one for me, or use a
cached one. It would be something like:
pico.getComponent(Juicer.class, myPeelerInstance);
as if this by this I could tell the container that it should use the
received object as one of the parameters for the construction of Juicer
instead of trying itself to create a Peeler.
Is this possible anyway? Am I going the wrong way here?
This question came to mind when I thought of one scenario that happens in
one of our applications, in which ObjectA that receives ObjectB and
manipulates (changes) it sometimes (depending on the situation) receives a
clone of an instance of ObjectB so that changes can be discarded if desired
after the manipulation ends.
I hope I made myself clear, please let me know if any further details are
needed.
Regards,
Andre