Skip to content

Commit

Permalink
Merge branch 'application-context' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekYRC committed Nov 29, 2020
2 parents 0f34f02 + 65d0b33 commit 5db289c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Binary file added assets/application-context-life-cycle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,15 @@ public class BeanFactoryProcessorAndBeanPostProcessorTest {
## 应用上下文ApplicationContext
> 分支:application-context
应用上下文ApplicationContext是spring中较之于BeanFactory更为先进的IOC容器,ApplicationContext除了拥有BeanFactory的所有功能外,还支持特殊类型bean如上一节中的BeanFactoryPostProcessor和BeanPostProcessor的自动识别、资源加载、容器事件和监听器、国际化支持、单例bean自动初始化等。

BeanFactory是spring的基础设施,面向spring本身;而ApplicationContext面向spring的使用者,应用场合使用ApplicationContext。

具体实现查看AbstractApplicationContext#refresh方法即可。注意BeanFactoryPostProcessor和BeanPostProcessor的自定识别,这样就可以在xml文件中配置二者而不需要像上一节一样手动添加到容器中了。

从bean的角度看,目前生命周期如下:

![](./assets/application-context-life-cycle.png)



Expand Down

0 comments on commit 5db289c

Please sign in to comment.