I have a rather basic question, which after using Spring for well over a year I am surprised I have to ask, because I thought I "got it".
Let's say I have an applicationContext which the following pertinent fragments (I've removed package names for brevity sake):
My previous (to today) understanding is that even though all three of the service beans have the same class, since they have a different id Spring would instantiate 3 different instances, one for each id.Code:<bean id="serviceOne" class="defaultHandler"> . . . <bean id="serviceTwo" class="defaultHandler"> . . . <bean id="serviceThree" class="defaultHandler"> . . . <bean id="serviceMap" class="java.util.HashMap"> <constructor-arg> <map> <entry key="one" value-ref="serviceOne"/> <entry key="two" value-ref="serviceTwo"/> <entry key="three" value-ref="serviceThree"/> </map> </constructor-arg> </bean>
However, I believe I am only seeing a single instance created. Currently to get around it I have added "singleton='false'" to each bean.
Is this expected? Are singletons based on the class, not the id?
Thanks,
Ron


Reply With Quote
