File: context.xml
"http://www.springframework.org/dtd/spring-beans.dtd">
factory-bean="nonStaticFactory" factory-method="getTestBeanInstance"/>
File: Main.java
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
class Main {
public static void main(String args[]) throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("context.xml");
TestBean testBeanObtainedViaStaticFactory = (TestBean) ctx
.getBean("testBeanObtainedViaNonStaticFactory");
}
}
class NonStaticFactory {
public TestBean getTestBeanInstance() {
return new TestBean();
}
}
class TestBean {
}