Hello!
Another stupid question:
I have beans like:
For so, beanA expects classA in getProp1Code:<bean id="beanA" class="ClassB"> <property name="prop1" ref="beanB"/> </bean> <bean id="beanB" class="BeanBFactory"> </bean>
For beanB I have singleton BeanFactory (BeanBFactory) used for making beanB
So, by default beanB created then application is initialized and tried to set beanB to beanA.
But I need to create beanB only then it is really started to be used in beanA - not during application start, but during user working...
In this case I should set into beanA not beanB - but it's factory - to create object via it then it is required.
OK, I changed ClassA::setProp1 so, it expects BeanBFactory - but still beanB is created during application initialization
And only if I remove
from my BeanBFactory everything started to work.Code:implements BeanFactory
So, is it correct solution, or there are some standard pattern exists in Spring for such cases?
Thank you for any advice



Reply With Quote