
Originally Posted by
ccudennec
I surely only want one instance of my factory bean. But: I want the factory bean to use new instances of my "targetObject" each time the factory method is called.
Yes, there is some confusion between the "singleton" property of MIFB and the singleton attribute in the xml bean element.
As you (and Adreas) say, you don't want to have a different instance of the factoryBean itself (so no need to set "singleton=false" on the bean element) but you do want every invocation of getObject to call the method.
I believe the fragment you provided is correct:
Code:
<bean id="getMailHost" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject" ref="globalsDao" />
<property name="targetMethod">
<value>getMailHost</value>
</property>
<property name="singleton" value="false" />
</bean>[/QUOTE]
Although I am not sure why you would want to call getMailHost multiple times???? But yes, that is the correct configuration.
@yatesco: only saw your post after I wrote mine. I think that's the point
Yes, I was replying to Andreas point