I have a somewhat tricky problem setting a dependency on a factory that has no default constructor but a getInstance method
I want to inject a dependency on the sampleFactory after I created it with getInstance(). My last try was a replacement of the first bean definition with this one, but it completely ignores the dependency:Code:<bean id="sampleFactory" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> <property name="targetClass"><value>sample.SampleFactory</value></property> <property name="targetMethod"><value>getInstance</value></property> </bean> <bean id="specialStuff" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> <property name="targetObject"><ref bean="sampleFactory"/></property> <property name="targetMethod"><value>getSpecialStuff</value></property> </bean>
The easiest way would be to make the constuctor of SampleFactory public, but there are some reasons not to do this...Code:<bean id="sampleFactory" class="sample.SampleFactory" factory-method="getInstance"> <property name="dependency"><ref bean="dependencyBean"/></property> </bean>
Does someone have any hints for this problem?
Felix


Reply With Quote
