Spring容器創建總結

根據源碼分析,Spring容器創建過程如下:

1、Spring容器在啓動的時候,先會保存所有註冊進來的Bean的定義信息

​     1、xml註冊bean

​     2、使用註解;@Service、@Bean、@Component、...

2、Spring容器會在合適的時機創建這些Bean

​     1、用到這個bean的時候,利用getBean方法創建bean,創建好以後保存在容器中

​     2、統一創建剩下所有bean的時候,即finishBeanFactoryInitialize();

3、後置處理器

​     1、每一個bean創建完成,都會使用各種後置處理器進行處理,來增強bean 的功能

​           AutowiredAnnotationBeanPostProcessor會處理自動注入功能

​           AnnotationAwareAspectJAutoProxyCreator來做AOP功能;

​           xxx

4、事件驅動模型:

​     ApplicationListener:事件監聽

​     ApplicationEventMulticaster:事件派發:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章