I have a bean factory class as follows:
public class BeanFactory {
public static BeanInterface getInstance(int id) {
return new Bean(id);
}
}
I want to use this class in spring container to get the instances of Instrument class, and have added a bean entry in applicationcontext.xml as follows:
<bean id="TestBean" class="com.test.beans.BeanFactory" factory-method="getInstance">
</bean>
But I am not able to find any way through which I can pass id to getInstance factory method.
Is there any way I can pass a parameter to this factory method?
EDIT: Consider the bean factory as scope=”prototype”. I want new instances of TestBean based on the value of ID.
The rules are the same as if it was normal Spring constructor, i.e. you can use
<contructor-arg value="..."/>From documentation