<!--[if !supportLists]-->① 1.<!--[endif]-->实例化(当我们的程序加载beans.xml文件),把我们的bean(前提是scope=singleton)实例化到内存
<!--[if !supportLists]-->② 2.调用set方法设置属性
<!--[if !supportLists]-->③ 3.如果你实现了bean名字关注接口(BeanNameAware) 则,可以通过setBeanName获取id号
<!--[if !supportLists]-->④ 4.<!--[endif]-->如果你实现了 bean工厂关注接口,(BeanFactoryAware),则可以获取BeanFactory
<!--[if !supportLists]-->⑤ 5.<!--[endif]-->如果你实现了 ApplicationContextAware接口,则调用方法
//该方法传递ApplicationContext
public void setApplicationContext(ApplicationContext arg0)
throws BeansException {
// TODO Auto-generated method stub
System.out.println("setApplicationContext"+arg0);
}
<!--[if !supportLists]-->⑥ 6.<!--[endif]-->如果bean 和 一个后置处理器关联,则会自动去调用 Object postProcessBeforeInitialization方法
<!--[if !supportLists]-->⑦ 7.<!--[endif]-->如果你实现InitializingBean 接口,则会调用 afterPropertiesSet
<!--[if !supportLists]-->⑧ 8.<!--[endif]-->如果自己在<bean init-method=”init” /> 则可以在bean定义自己的初始化方法.
<!--[if !supportLists]-->⑨ 9.<!--[endif]-->如果bean 和 一个后置处理器关联,则会自动去调用 Object postProcessAfterInitialization方法
<!--[if !supportLists]-->⑩ 10. <!--[endif]-->使用我们的bean
11. 容器关闭
12. 可以通过实现DisposableBean 接口来调用方法 destory
13. 可以在<bean destory-method=”fun1”/> 调用定制的销毁方法
小结: 我们实际开发中往往,没有用的这么的过程,常见的是:
1->2->6->10->9->11