Skip to content

Commit 66a9807

Browse files
author
bingqiang.lin
committed
添加注释
1 parent 04ab93c commit 66a9807

File tree

5 files changed

+279
-0
lines changed

5 files changed

+279
-0
lines changed

BeanFactory.uml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Diagram>
3+
<ID>JAVA</ID>
4+
<OriginalElement>org.springframework.beans.factory.BeanFactory</OriginalElement>
5+
<nodes>
6+
<node x="365.3205128205128" y="79.0">org.springframework.beans.factory.HierarchicalBeanFactory</node>
7+
<node x="198.32051282051282" y="79.0">org.springframework.core.io.ResourceLoader</node>
8+
<node x="0.0" y="237.0">org.springframework.context.ConfigurableApplicationContext</node>
9+
<node x="620.75" y="0.0">org.springframework.beans.factory.BeanFactory</node>
10+
<node x="264.99999999999994" y="237.0">org.springframework.web.context.WebApplicationContext</node>
11+
<node x="776.4455128205128" y="79.0">org.springframework.beans.factory.config.AutowireCapableBeanFactory</node>
12+
<node x="602.625" y="237.0">org.springframework.beans.factory.support.DefaultListableBeanFactory</node>
13+
<node x="411.0705128205128" y="158.0">org.springframework.beans.factory.config.ConfigurableBeanFactory</node>
14+
<node x="206.75" y="158.0">org.springframework.context.ApplicationContext</node>
15+
<node x="33.32051282051282" y="79.0">org.springframework.context.MessageSource</node>
16+
<node x="584.4455128205128" y="79.0">org.springframework.beans.factory.ListableBeanFactory</node>
17+
</nodes>
18+
<notes />
19+
<edges>
20+
<edge source="org.springframework.beans.factory.HierarchicalBeanFactory" target="org.springframework.beans.factory.BeanFactory">
21+
<point x="0.0" y="-14.5" />
22+
<point x="463.8205128205128" y="54.0" />
23+
<point x="641.5833333333333" y="54.0" />
24+
<point x="-41.66666666666663" y="14.5" />
25+
</edge>
26+
<edge source="org.springframework.beans.factory.config.AutowireCapableBeanFactory" target="org.springframework.beans.factory.BeanFactory">
27+
<point x="0.0" y="-14.5" />
28+
<point x="890.9455128205128" y="54.0" />
29+
<point x="724.9166666666665" y="54.0" />
30+
<point x="41.66666666666663" y="14.5" />
31+
</edge>
32+
<edge source="org.springframework.beans.factory.support.DefaultListableBeanFactory" target="org.springframework.beans.factory.config.ConfigurableBeanFactory">
33+
<point x="-72.0" y="-14.5" />
34+
<point x="638.625" y="212.0" />
35+
<point x="513.0705128205128" y="212.0" />
36+
<point x="0.0" y="14.5" />
37+
</edge>
38+
<edge source="org.springframework.beans.factory.ListableBeanFactory" target="org.springframework.beans.factory.BeanFactory">
39+
<point x="0.0" y="-14.5" />
40+
<point x="670.4455128205128" y="54.0" />
41+
<point x="683.25" y="54.0" />
42+
<point x="0.0" y="14.5" />
43+
</edge>
44+
<edge source="org.springframework.beans.factory.support.DefaultListableBeanFactory" target="org.springframework.beans.factory.ListableBeanFactory">
45+
<point x="0.0" y="-14.5" />
46+
<point x="710.625" y="212.0" />
47+
<point x="713.4455128205128" y="212.0" />
48+
<point x="43.0" y="14.5" />
49+
</edge>
50+
<edge source="org.springframework.context.ConfigurableApplicationContext" target="org.springframework.context.ApplicationContext">
51+
<point x="0.0" y="-14.5" />
52+
<point x="122.5" y="212.0" />
53+
<point x="248.25" y="212.0" />
54+
<point x="-41.5" y="14.5" />
55+
</edge>
56+
<edge source="org.springframework.context.ApplicationContext" target="org.springframework.beans.factory.HierarchicalBeanFactory">
57+
<point x="20.75" y="-14.5" />
58+
<point x="310.5" y="128.0" />
59+
<point x="414.5705128205128" y="128.0" />
60+
<point x="-49.25" y="14.5" />
61+
</edge>
62+
<edge source="org.springframework.context.ApplicationContext" target="org.springframework.core.io.ResourceLoader">
63+
<point x="-20.75" y="-14.5" />
64+
<point x="269.0" y="138.0" />
65+
<point x="271.8205128205128" y="138.0" />
66+
<point x="0.0" y="14.5" />
67+
</edge>
68+
<edge source="org.springframework.beans.factory.support.DefaultListableBeanFactory" target="org.springframework.beans.factory.config.AutowireCapableBeanFactory">
69+
<point x="72.00000000000003" y="-14.5" />
70+
<point x="782.625" y="212.0" />
71+
<point x="890.9455128205128" y="212.0" />
72+
<point x="0.0" y="14.5" />
73+
</edge>
74+
<edge source="org.springframework.context.ApplicationContext" target="org.springframework.beans.factory.ListableBeanFactory">
75+
<point x="62.25" y="-14.5" />
76+
<point x="352.0" y="138.0" />
77+
<point x="627.4455128205128" y="138.0" />
78+
<point x="-43.0" y="14.5" />
79+
</edge>
80+
<edge source="org.springframework.context.ApplicationContext" target="org.springframework.context.MessageSource">
81+
<point x="-62.25" y="-14.5" />
82+
<point x="227.5" y="138.0" />
83+
<point x="105.82051282051282" y="138.0" />
84+
<point x="0.0" y="14.5" />
85+
</edge>
86+
<edge source="org.springframework.beans.factory.config.ConfigurableBeanFactory" target="org.springframework.beans.factory.HierarchicalBeanFactory">
87+
<point x="0.0" y="-14.5" />
88+
<point x="49.25" y="14.5" />
89+
</edge>
90+
<edge source="org.springframework.web.context.WebApplicationContext" target="org.springframework.context.ApplicationContext">
91+
<point x="0.0" y="-14.5" />
92+
<point x="361.99999999999994" y="212.0" />
93+
<point x="331.25" y="212.0" />
94+
<point x="41.5" y="14.5" />
95+
</edge>
96+
</edges>
97+
<settings layout="Hierarchic Group" zoom="1.0" x="677.5" y="133.0" />
98+
<SelectedNodes />
99+
<Categories />
100+
<SCOPE>All</SCOPE>
101+
<VISIBILITY>private</VISIBILITY>
102+
</Diagram>
103+

FileSystemXmlApplicationContext.uml

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Diagram>
3+
<ID>JAVA</ID>
4+
<OriginalElement>org.springframework.context.support.FileSystemXmlApplicationContext</OriginalElement>
5+
<nodes>
6+
<node x="0.0" y="79.0">org.springframework.beans.factory.HierarchicalBeanFactory</node>
7+
<node x="1176.6666666666667" y="642.0">org.springframework.context.support.FileSystemXmlApplicationContext</node>
8+
<node x="1211.6100000000001" y="0.0">org.springframework.core.io.ResourceLoader</node>
9+
<node x="1182.6666666666667" y="563.0">org.springframework.context.support.AbstractXmlApplicationContext</node>
10+
<node x="1423.746666666667" y="326.0">org.springframework.beans.factory.Aware</node>
11+
<node x="1220.0" y="79.0">java.lang.AutoCloseable</node>
12+
<node x="519.5" y="168.0">org.springframework.context.ApplicationContext</node>
13+
<node x="1230.746666666667" y="405.0">org.springframework.beans.factory.InitializingBean</node>
14+
<node x="1137.6666666666667" y="484.0">org.springframework.context.support.AbstractRefreshableConfigApplicationContext</node>
15+
<node x="860.7466666666668" y="168.0">org.springframework.context.Lifecycle</node>
16+
<node x="625.5" y="0.0">java.lang.FunctionalInterface</node>
17+
<node x="955.7466666666668" y="326.0">org.springframework.context.support.AbstractApplicationContext</node>
18+
<node x="1377.0" y="79.0">org.springframework.core.io.DefaultResourceLoader</node>
19+
<node x="138.25" y="0.0">org.springframework.beans.factory.BeanFactory</node>
20+
<node x="409.0" y="79.0">org.springframework.core.env.EnvironmentCapable</node>
21+
<node x="1235.0" y="168.0">java.io.Closeable</node>
22+
<node x="791.6666666666667" y="247.0">org.springframework.context.ConfigurableApplicationContext</node>
23+
<node x="604.0" y="79.0">org.springframework.context.ApplicationEventPublisher</node>
24+
<node x="833.0" y="79.0">org.springframework.core.io.support.ResourcePatternResolver</node>
25+
<node x="1390.746666666667" y="405.0">org.springframework.beans.factory.BeanNameAware</node>
26+
<node x="919.7466666666668" y="405.0">org.springframework.context.support.AbstractRefreshableApplicationContext</node>
27+
<node x="1055.0" y="79.0">org.springframework.context.MessageSource</node>
28+
<node x="217.0" y="79.0">org.springframework.beans.factory.ListableBeanFactory</node>
29+
</nodes>
30+
<notes />
31+
<edges>
32+
<edge source="org.springframework.context.ApplicationContext" target="org.springframework.core.env.EnvironmentCapable">
33+
<point x="-13.833333333333371" y="-14.5" />
34+
<point x="588.6666666666666" y="128.0" />
35+
<point x="496.5" y="128.0" />
36+
<point x="0.0" y="14.5" />
37+
</edge>
38+
<edge source="org.springframework.context.support.AbstractXmlApplicationContext" target="org.springframework.context.support.AbstractRefreshableConfigApplicationContext">
39+
<point x="0.0" y="-14.5" />
40+
<point x="0.0" y="14.5" />
41+
</edge>
42+
<edge source="org.springframework.context.support.AbstractRefreshableConfigApplicationContext" target="org.springframework.beans.factory.BeanNameAware">
43+
<point x="110.66666666666674" y="-14.5" />
44+
<point x="1414.3333333333335" y="459.0" />
45+
<point x="1466.746666666667" y="459.0" />
46+
<point x="0.0" y="14.5" />
47+
</edge>
48+
<edge source="org.springframework.context.support.AbstractRefreshableConfigApplicationContext" target="org.springframework.context.support.AbstractRefreshableApplicationContext">
49+
<point x="-110.66666666666674" y="-14.5" />
50+
<point x="1193.0" y="459.0" />
51+
<point x="1065.246666666667" y="459.0" />
52+
<point x="0.0" y="14.5" />
53+
</edge>
54+
<edge source="org.springframework.core.io.support.ResourcePatternResolver" target="org.springframework.core.io.ResourceLoader">
55+
<point x="0.0" y="-14.5" />
56+
<point x="934.0" y="54.0" />
57+
<point x="1248.3600000000001" y="54.0" />
58+
<point x="-36.75" y="14.5" />
59+
</edge>
60+
<edge source="org.springframework.beans.factory.HierarchicalBeanFactory" target="org.springframework.beans.factory.BeanFactory">
61+
<point x="0.0" y="-14.5" />
62+
<point x="98.5" y="54.0" />
63+
<point x="169.5" y="54.0" />
64+
<point x="-31.25" y="14.5" />
65+
</edge>
66+
<edge source="org.springframework.context.support.AbstractApplicationContext" target="org.springframework.core.io.DefaultResourceLoader">
67+
<point x="54.75" y="-14.5" />
68+
<point x="1119.996666666667" y="301.0" />
69+
<point x="1472.5" y="301.0" />
70+
<point x="0.0" y="14.5" />
71+
</edge>
72+
<edge source="org.springframework.context.support.AbstractRefreshableConfigApplicationContext" target="org.springframework.beans.factory.InitializingBean">
73+
<point x="0.0" y="-14.5" />
74+
<point x="1303.6666666666667" y="459.0" />
75+
<point x="1300.746666666667" y="459.0" />
76+
<point x="0.0" y="14.5" />
77+
</edge>
78+
<edge source="org.springframework.beans.factory.ListableBeanFactory" target="org.springframework.beans.factory.BeanFactory">
79+
<point x="0.0" y="-14.5" />
80+
<point x="303.0" y="54.0" />
81+
<point x="232.0" y="54.0" />
82+
<point x="31.25" y="14.5" />
83+
</edge>
84+
<edge source="org.springframework.core.io.DefaultResourceLoader" target="org.springframework.core.io.ResourceLoader">
85+
<point x="0.0" y="-14.5" />
86+
<point x="1472.5" y="54.0" />
87+
<point x="1321.8600000000001" y="54.0" />
88+
<point x="36.75" y="14.5" />
89+
</edge>
90+
<edge source="org.springframework.context.support.AbstractRefreshableApplicationContext" target="org.springframework.context.support.AbstractApplicationContext">
91+
<point x="0.0" y="-14.5" />
92+
<point x="0.0" y="14.5" />
93+
</edge>
94+
<edge source="org.springframework.beans.factory.BeanNameAware" target="org.springframework.beans.factory.Aware">
95+
<point x="0.0" y="-14.5" />
96+
<point x="0.0" y="14.5" />
97+
</edge>
98+
<edge source="org.springframework.context.ConfigurableApplicationContext" target="org.springframework.context.ApplicationContext">
99+
<point x="-81.66666666666674" y="-14.5" />
100+
<point x="832.5" y="222.0" />
101+
<point x="602.5" y="222.0" />
102+
<point x="0.0" y="14.5" />
103+
</edge>
104+
<edge source="org.springframework.context.ApplicationContext" target="org.springframework.beans.factory.HierarchicalBeanFactory">
105+
<point x="-69.16666666666663" y="-14.5" />
106+
<point x="533.3333333333334" y="148.0" />
107+
<point x="98.5" y="148.0" />
108+
<point x="0.0" y="14.5" />
109+
</edge>
110+
<edge source="org.springframework.context.ConfigurableApplicationContext" target="java.io.Closeable">
111+
<point x="81.66666666666663" y="-14.5" />
112+
<point x="995.8333333333334" y="222.0" />
113+
<point x="1288.5" y="222.0" />
114+
<point x="0.0" y="14.5" />
115+
</edge>
116+
<edge source="java.io.Closeable" target="java.lang.AutoCloseable">
117+
<point x="0.0" y="-14.5" />
118+
<point x="0.0" y="14.5" />
119+
</edge>
120+
<edge source="org.springframework.context.ApplicationContext" target="org.springframework.context.ApplicationEventPublisher">
121+
<point x="13.833333333333371" y="-14.5" />
122+
<point x="616.3333333333334" y="128.0" />
123+
<point x="708.5" y="128.0" />
124+
<point x="0.0" y="14.5" />
125+
</edge>
126+
<edge source="org.springframework.context.ApplicationContext" target="org.springframework.context.MessageSource">
127+
<point x="69.16666666666663" y="-14.5" />
128+
<point x="671.6666666666666" y="148.0" />
129+
<point x="1127.5" y="148.0" />
130+
<point x="0.0" y="14.5" />
131+
</edge>
132+
<edge source="org.springframework.context.ApplicationContext" target="org.springframework.beans.factory.ListableBeanFactory">
133+
<point x="-41.5" y="-14.5" />
134+
<point x="561.0" y="138.0" />
135+
<point x="303.0" y="138.0" />
136+
<point x="0.0" y="14.5" />
137+
</edge>
138+
<edge source="org.springframework.context.ApplicationEventPublisher" target="java.lang.FunctionalInterface">
139+
<point x="0.0" y="-14.5" />
140+
<point x="0.0" y="14.5" />
141+
</edge>
142+
<edge source="org.springframework.context.support.FileSystemXmlApplicationContext" target="org.springframework.context.support.AbstractXmlApplicationContext">
143+
<point x="0.0" y="-14.5" />
144+
<point x="0.0" y="14.5" />
145+
</edge>
146+
<edge source="org.springframework.context.ApplicationContext" target="org.springframework.core.io.support.ResourcePatternResolver">
147+
<point x="41.5" y="-14.5" />
148+
<point x="644.0" y="138.0" />
149+
<point x="934.0" y="138.0" />
150+
<point x="0.0" y="14.5" />
151+
</edge>
152+
<edge source="org.springframework.context.ConfigurableApplicationContext" target="org.springframework.context.Lifecycle">
153+
<point x="0.0" y="-14.5" />
154+
<point x="914.1666666666667" y="222.0" />
155+
<point x="911.2466666666668" y="222.0" />
156+
<point x="0.0" y="14.5" />
157+
</edge>
158+
<edge source="org.springframework.context.support.AbstractApplicationContext" target="org.springframework.context.ConfigurableApplicationContext">
159+
<point x="-54.75" y="-14.5" />
160+
<point x="1010.4966666666668" y="301.0" />
161+
<point x="914.1666666666667" y="301.0" />
162+
<point x="0.0" y="14.5" />
163+
</edge>
164+
</edges>
165+
<settings layout="Hierarchic Group" zoom="0.8803526448362721" x="784.0" y="336.10157367668097" />
166+
<SelectedNodes />
167+
<Categories />
168+
<SCOPE>All</SCOPE>
169+
<VISIBILITY>private</VISIBILITY>
170+
</Diagram>
171+

spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,8 @@ public void refresh() throws BeansException, IllegalStateException {
518518
prepareRefresh();
519519

520520
// Tell the subclass to refresh the internal bean factory.
521+
// 初始化BeanFactory
522+
// 在这一步中,Spring将配置文件中的配置信息装入容器的bean定义注册表中(BeanDefinitionRegistry), 但并未实例化Bean
521523
ConfigurableListableBeanFactory beanFactory = obtainFreshBeanFactory();
522524

523525
// Prepare the bean factory for use in this context.

spring-context/src/main/java/org/springframework/context/support/AbstractRefreshableConfigApplicationContext.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public void setConfigLocations(@Nullable String... locations) {
7878
Assert.noNullElements(locations, "Config locations must not be null");
7979
this.configLocations = new String[locations.length];
8080
for (int i = 0; i < locations.length; i++) {
81+
//路径解析
8182
this.configLocations[i] = resolvePath(locations[i]).trim();
8283
}
8384
}

spring-context/src/main/java/org/springframework/context/support/FileSystemXmlApplicationContext.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ public FileSystemXmlApplicationContext(
136136
String[] configLocations, boolean refresh, @Nullable ApplicationContext parent)
137137
throws BeansException {
138138

139+
//设置父容器
139140
super(parent);
141+
//设置配置文件路径
140142
setConfigLocations(configLocations);
141143
if (refresh) {
142144
refresh();

0 commit comments

Comments
 (0)