public class MainApplication { public static void main(String [] args) { // Read the configuration file ApplicationContext ctx = new FileSystemXmlApplicationContext("springconfig.xml");
//Instantiate an object IBusinessLogic testObject = (IBusinessLogic) ctx.getBean("businesslogicbean");
// Execute the public // method of the bean testObject.foo(); } } 在BusinessLogic类及其关联接口中没有什么需要注重的。但是,MainApplication类初始化BusinessLogic对象的方式很有意思。通过使用ctx.getBean("businesslogicbean")调用,MainApplication将加载和治理BusinessLogic类的bean实例的任务转交给了Spring框架。