diff --git a/.gitignore b/.gitignore
index a1c2a238a965f004ff76978ac1086aa6fe95caea..b50db210cb7747d015fb51900471f6537a73a1eb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,6 +18,7 @@
*.zip
*.tar.gz
*.rar
+**/*.iml
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
diff --git "a/\344\273\243\347\240\201/spring-annotation/pom.xml" "b/\344\273\243\347\240\201/spring-annotation/pom.xml"
index dec2985e563a9b2306c136fca624ff6773f61e2b..3163ed05c4e8ce784bd621dc4a7fd818d22b5f11 100644
--- "a/\344\273\243\347\240\201/spring-annotation/pom.xml"
+++ "b/\344\273\243\347\240\201/spring-annotation/pom.xml"
@@ -11,19 +11,22 @@
org.springframework
spring-context
- 4.3.12.RELEASE
+
+ 4.3.26.RELEASE
org.springframework
spring-aspects
- 4.3.12.RELEASE
+
+ 4.3.26.RELEASE
org.springframework
spring-jdbc
- 4.3.12.RELEASE
+
+ 4.3.26.RELEASE
diff --git "a/\344\273\243\347\240\201/spring-annotation/src/main/java/com/atguigu/config/MainConfig2.java" "b/\344\273\243\347\240\201/spring-annotation/src/main/java/com/atguigu/config/MainConfig2.java"
index 8fc12012aa1564b6f593a247a31dc09a45e2d3c1..2dabed8d8f3e0804af498561da713df5b779d848 100644
--- "a/\344\273\243\347\240\201/spring-annotation/src/main/java/com/atguigu/config/MainConfig2.java"
+++ "b/\344\273\243\347\240\201/spring-annotation/src/main/java/com/atguigu/config/MainConfig2.java"
@@ -17,7 +17,6 @@ import com.atguigu.condition.LinuxCondition;
import com.atguigu.condition.MyImportBeanDefinitionRegistrar;
import com.atguigu.condition.MyImportSelector;
import com.atguigu.condition.WindowsCondition;
-import com.atguigu.test.IOCTest;
//类中组件统一设置。满足当前条件,这个类中配置的所有bean注册才能生效;
@Conditional({WindowsCondition.class})
@@ -28,7 +27,7 @@ public class MainConfig2 {
//默认是单实例的
/**
- * ConfigurableBeanFactory#SCOPE_PROTOTYPE
+ * ConfigurableBeanFactory#SCOPE_PROTOTYPE
* @see ConfigurableBeanFactory#SCOPE_SINGLETON
* @see org.springframework.web.context.WebApplicationContext#SCOPE_REQUEST request
* @see org.springframework.web.context.WebApplicationContext#SCOPE_SESSION sesssion
diff --git "a/\344\273\243\347\240\201/spring-annotation/src/main/resources/SpringSource.txt" "b/\344\273\243\347\240\201/spring-annotation/src/main/resources/SpringSource.txt"
index eb6647857d523e32436eaccd0c309f50b36e0cb9..9fb2e21173db0e4f2479bb5066cd807bc801ff99 100644
--- "a/\344\273\243\347\240\201/spring-annotation/src/main/resources/SpringSource.txt"
+++ "b/\344\273\243\347\240\201/spring-annotation/src/main/resources/SpringSource.txt"
@@ -3,12 +3,14 @@ Spring
1)、initPropertySources()初始化一些属性设置;子类自定义个性化的属性设置方法;
2)、getEnvironment().validateRequiredProperties();检验属性的合法等
3)、earlyApplicationEvents= new LinkedHashSet();保存容器中的一些早期的事件;
+
2、obtainFreshBeanFactory();获取BeanFactory;
1)、refreshBeanFactory();刷新【创建】BeanFactory;
创建了一个this.beanFactory = new DefaultListableBeanFactory();
设置id;
2)、getBeanFactory();返回刚才GenericApplicationContext创建的BeanFactory对象;
3)、将创建的BeanFactory【DefaultListableBeanFactory】返回;
+
3、prepareBeanFactory(beanFactory);BeanFactory的预准备工作(BeanFactory进行一些设置);
1)、设置BeanFactory的类加载器、支持表达式解析器...
2)、添加部分BeanPostProcessor【ApplicationContextAwareProcessor】
@@ -21,13 +23,18 @@ Spring
environment【ConfigurableEnvironment】、
systemProperties【Map】、
systemEnvironment【Map】
+
4、postProcessBeanFactory(beanFactory);BeanFactory准备工作完成后进行的后置处理工作;
1)、子类通过重写这个方法来在BeanFactory创建并预准备完成以后做进一步的设置
+
======================以上是BeanFactory的创建及预准备工作==================================
+
+
5、invokeBeanFactoryPostProcessors(beanFactory);执行BeanFactoryPostProcessor的方法;
BeanFactoryPostProcessor:BeanFactory的后置处理器。在BeanFactory标准初始化之后执行的;
两个接口:BeanFactoryPostProcessor、BeanDefinitionRegistryPostProcessor
1)、执行BeanFactoryPostProcessor的方法;
+
先执行BeanDefinitionRegistryPostProcessor
1)、获取所有的BeanDefinitionRegistryPostProcessor;
2)、看先执行实现了PriorityOrdered优先级接口的BeanDefinitionRegistryPostProcessor、
@@ -46,6 +53,7 @@ Spring
postProcessor.postProcessBeanFactory()
4)、最后执行没有实现任何优先级或者是顺序接口的BeanFactoryPostProcessor;
postProcessor.postProcessBeanFactory()
+
6、registerBeanPostProcessors(beanFactory);注册BeanPostProcessor(Bean的后置处理器)【 intercept bean creation】
不同接口类型的BeanPostProcessor;在Bean创建前后的执行时机是不一样的
BeanPostProcessor、
@@ -63,6 +71,7 @@ Spring
5)、最终注册MergedBeanDefinitionPostProcessor;
6)、注册一个ApplicationListenerDetector;来在Bean创建完成后检查是否是ApplicationListener,如果是
applicationContext.addApplicationListener((ApplicationListener>) bean);
+
7、initMessageSource();初始化MessageSource组件(做国际化功能;消息绑定,消息解析);
1)、获取BeanFactory
2)、看容器中是否有id为messageSource的,类型是MessageSource的组件
@@ -71,23 +80,27 @@ Spring
3)、把创建好的MessageSource注册在容器中,以后获取国际化配置文件的值的时候,可以自动注入MessageSource;
beanFactory.registerSingleton(MESSAGE_SOURCE_BEAN_NAME, this.messageSource);
MessageSource.getMessage(String code, Object[] args, String defaultMessage, Locale locale);
+
8、initApplicationEventMulticaster();初始化事件派发器;
1)、获取BeanFactory
2)、从BeanFactory中获取applicationEventMulticaster的ApplicationEventMulticaster;
3)、如果上一步没有配置;创建一个SimpleApplicationEventMulticaster
4)、将创建的ApplicationEventMulticaster添加到BeanFactory中,以后其他组件直接自动注入
+
9、onRefresh();留给子容器(子类)
1、子类重写这个方法,在容器刷新的时候可以自定义逻辑;
+
10、registerListeners();给容器中将所有项目里面的ApplicationListener注册进来;
1、从容器中拿到所有的ApplicationListener
2、将每个监听器添加到事件派发器中;
getApplicationEventMulticaster().addApplicationListenerBean(listenerBeanName);
3、派发之前步骤产生的事件;
+
11、finishBeanFactoryInitialization(beanFactory);初始化所有剩下的单实例bean;
1、beanFactory.preInstantiateSingletons();初始化后剩下的单实例bean
1)、获取容器中的所有Bean,依次进行初始化和创建对象
2)、获取Bean的定义信息;RootBeanDefinition
- 3)、Bean不是抽象的,是单实例的,是懒加载;
+ 3)、Bean不是抽象的,是单实例的,不是懒加载;
1)、判断是否是FactoryBean;是否是实现FactoryBean接口的Bean;
2)、不是工厂Bean。利用getBean(beanName);创建对象
0、getBean(beanName); ioc.getBean();
@@ -134,6 +147,7 @@ Spring
ioc容器就是这些Map;很多的Map里面保存了单实例Bean,环境信息。。。。;
所有Bean都利用getBean创建完成以后;
检查所有的Bean是否是SmartInitializingSingleton接口的;如果是;就执行afterSingletonsInstantiated();
+
12、finishRefresh();完成BeanFactory的初始化创建工作;IOC容器就创建完成;
1)、initLifecycleProcessor();初始化和生命周期有关的后置处理器;LifecycleProcessor
默认从容器中找是否有lifecycleProcessor的组件【LifecycleProcessor】;如果没有new DefaultLifecycleProcessor();
diff --git "a/\344\273\243\347\240\201/spring-annotation/target/classes/META-INF/MANIFEST.MF" "b/\344\273\243\347\240\201/spring-annotation/target/classes/META-INF/MANIFEST.MF"
deleted file mode 100644
index 385d627e4c3b4b4318a91988e69c95da29c941c1..0000000000000000000000000000000000000000
--- "a/\344\273\243\347\240\201/spring-annotation/target/classes/META-INF/MANIFEST.MF"
+++ /dev/null
@@ -1,5 +0,0 @@
-Manifest-Version: 1.0
-Built-By: lfy
-Build-Jdk: 1.8.0_112
-Created-By: Maven Integration for Eclipse
-
diff --git "a/\344\273\243\347\240\201/spring-annotation/target/classes/META-INF/maven/com.atguigu/spring-annotation/pom.properties" "b/\344\273\243\347\240\201/spring-annotation/target/classes/META-INF/maven/com.atguigu/spring-annotation/pom.properties"
deleted file mode 100644
index 6b93dc614771494b1a5800e53b98a52d2a119b93..0000000000000000000000000000000000000000
--- "a/\344\273\243\347\240\201/spring-annotation/target/classes/META-INF/maven/com.atguigu/spring-annotation/pom.properties"
+++ /dev/null
@@ -1,7 +0,0 @@
-#Generated by Maven Integration for Eclipse
-#Fri Dec 22 14:54:11 GMT+08:00 2017
-version=0.0.1-SNAPSHOT
-groupId=com.atguigu
-m2e.projectName=spring-annotation
-m2e.projectLocation=F\:\\share_source\\spring\\spring-annotation
-artifactId=spring-annotation
diff --git "a/\344\273\243\347\240\201/spring-annotation/target/classes/META-INF/maven/com.atguigu/spring-annotation/pom.xml" "b/\344\273\243\347\240\201/spring-annotation/target/classes/META-INF/maven/com.atguigu/spring-annotation/pom.xml"
deleted file mode 100644
index dec2985e563a9b2306c136fca624ff6773f61e2b..0000000000000000000000000000000000000000
--- "a/\344\273\243\347\240\201/spring-annotation/target/classes/META-INF/maven/com.atguigu/spring-annotation/pom.xml"
+++ /dev/null
@@ -1,61 +0,0 @@
-
- 4.0.0
- com.atguigu
- spring-annotation
- 0.0.1-SNAPSHOT
-
-
-
-
-
- org.springframework
- spring-context
- 4.3.12.RELEASE
-
-
-
- org.springframework
- spring-aspects
- 4.3.12.RELEASE
-
-
-
- org.springframework
- spring-jdbc
- 4.3.12.RELEASE
-
-
-
- junit
- junit
- 4.12
- test
-
-
-
- javax.inject
- javax.inject
- 1
-
-
-
-
- c3p0
- c3p0
- 0.9.1.2
-
-
-
-
- mysql
- mysql-connector-java
- 5.1.44
-
-
-
-
-
-
-
-
\ No newline at end of file