I have a MainClass which have 2 variables. I would like to pass those 2 values to a springframework bean class "Test". how do I define that in applicationContext.xml and also how do I pass those 2 variable values to the bean "Test".
Ex:
class MainClass { public int var1; public int var2; public Test test; public void setVar1(int var11) { var1 = var11; } public void setVar2(int var22) { var2 = var22; } public static void main(String args[]) { ApplicationContext context = new FileSystemXmlApplicationContext("applicationContext.xml"); Test = context.getBean("test"); } } ------------ TEST class ------------
public class Test { public Test (int var1, int var2) {} } ------------- applicationContext.xml -------------
<bean id="test" class="com.path.test"> <constructor-arg index="0" type="int" value="????"/> <constructor-arg index="1" type="int" value="????"/> </bean>