Hello. I've got a problem.
I have a structure of beans like this:
Each of subBeanN contains a list of handlers. Each topBean instance has unique instances of subBeanN, and each of subBeanN contains unique instances of handlers, i.e. there are no singletons.
Now for some of the beans I have to set the same instance of object Foo into some properties. I naively tried this:
Spring complains that uniqueFoo is not found in handler1. Yeah. Sure.
<bean id="topBean" ... >
<property name="subBean1" ref="subBean1"/>
<bean id="uniqueFoo" class="someFactory"/>
<bean id="subBean1" ... >
<bean id="handler1" class="...">
<property name="foo" ref="uniqueFoo"/>
But if I move bean uniqueFoo out of the topBean, then handler1 will get a different instance than topBean (factory is not singleton one).
I cannot make the factory singleton since there are more than one topBean are created at the same time, and those must have unique instances of foo.
Is there a way to achive what I want through the pure configuration?
May be, there should be one more instance type: unique inside a given bean tree (i.e. from topBean and down)?