实例化前->推断构造方法
![](https://img.haomeiwen.com/i4464433/ec258c2f902796b4.png)
![](https://img.haomeiwen.com/i4464433/7af579c90088f9d5.png)
- 关于AutoWired Resource Value注解也是通过
postProcessProperties 这个后置处理来实现的.
- Aop也是基于初始化后实现的.
- 关于BeanDefinition的描述
![](https://img.haomeiwen.com/i4464433/0e4d3b916daab3ec.png)
- Disposable AutoCloseable ,destroyMethodName
三种入参,但是出参只有一个,所以需要用到适配器模式.
@Configuration
public class BeanDestoryAdapter implements DisposableBean,Runnable {
private Bean bean;
public BeanDestoryAdapter(Bean bean) {
//传递Bean 进来,有三种Bean销毁的方式
//入参三种,销毁只有一种
this.bean = bean;
}
@Override
public void run() {
}
@Override
public void destroy() throws Exception {
DisposableBean disposableBean = (DisposableBean) bean;
disposableBean.destroy();
//有destory方法 或者 xxx接口的Bean
//determineDestroyMethod
}
}
- 这个就是典型的适配器模式. (注意理解这个思想)
将实现了DisposableBean接口,AutoCloseable,或者标记@PreDestroy注解的方法通过Adapter做适配。
- close方法
ContextClosedEvent事件
DisposableBean 下 Destory ,可能还有相互关联的bean,inner beans,也会从单例池中进行移除.
网友评论