Hi, simple question from a newbie
I can construct an empty basket like so:
basket = (Basket)beanFactory.getBean("Basket");
if it has dependencies that are set within the config file, they will be created by the spring container.
However, what happens if i want to actually pass some other parameters to the constructor, like some things to add to the basket (which are only known at runtime)?
Can I pass anything else in the call to the bean factory?
Obviously, i can do
basket = (Basket)beanFactory.getBean("Basket");
basket.addItem(a);
basket.addItem(b);
but it doesn't seem as elegant.
Also, maybe the basket doesn't have a parameterless constructor - maybe it always needs to be passed a reference to something else. In this case, how would we use spring to construct the item if we can't pass in a reference on the call to the bean factory?
Many thanks!
Craig


Reply With Quote
