Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
Spring_resource_analysis
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
WeifengSun
Spring_resource_analysis
Commits
94e1e9e0
Commit
94e1e9e0
authored
Aug 21, 2022
by
SunWei峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IOCAOP融汇贯通
parent
7f8f7bc7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
26 additions
and
19 deletions
+26
-19
spring-framework-main/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java
+2
-1
spring-framework-main/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java
+11
-7
spring-framework-main/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java
+4
-4
spring-framework-main/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java
+1
-1
spring-framework-main/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java
+4
-2
spring-framework-main/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java
+2
-2
spring-framework-main/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java
+2
-2
No files found.
spring-framework-main/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java
View file @
94e1e9e0
...
@@ -141,6 +141,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
...
@@ -141,6 +141,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
private
final
Map
<
Object
,
Class
<?>>
proxyTypes
=
new
ConcurrentHashMap
<>(
16
);
private
final
Map
<
Object
,
Class
<?>>
proxyTypes
=
new
ConcurrentHashMap
<>(
16
);
// TODO: 2022/8/19 before方法中用到,AOP中见到要联想到
private
final
Map
<
Object
,
Boolean
>
advisedBeans
=
new
ConcurrentHashMap
<>(
256
);
private
final
Map
<
Object
,
Boolean
>
advisedBeans
=
new
ConcurrentHashMap
<>(
256
);
...
@@ -292,7 +293,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
...
@@ -292,7 +293,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
// 根据给定的 bean 的 class 和 name 构建出一个key 格式是 beanClassName_beanName
// 根据给定的 bean 的 class 和 name 构建出一个key 格式是 beanClassName_beanName
Object
cacheKey
=
getCacheKey
(
bean
.
getClass
(),
beanName
);
Object
cacheKey
=
getCacheKey
(
bean
.
getClass
(),
beanName
);
if
(
this
.
earlyProxyReferences
.
remove
(
cacheKey
)
!=
bean
)
{
if
(
this
.
earlyProxyReferences
.
remove
(
cacheKey
)
!=
bean
)
{
//
如果他适合做代理,则需要封装指定Bean
//
不相等说明之前没有put过,就需要封装指定Bean,
return
wrapIfNecessary
(
bean
,
beanName
,
cacheKey
);
return
wrapIfNecessary
(
bean
,
beanName
,
cacheKey
);
}
}
}
}
...
...
spring-framework-main/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java
View file @
94e1e9e0
...
@@ -570,7 +570,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
...
@@ -570,7 +570,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
// 单例情况下清除缓存。这里保存的是 FactoryBean 和 BeanWrapper 的映射关系。
// 单例情况下清除缓存。这里保存的是 FactoryBean 和 BeanWrapper 的映射关系。
// factoryBeanInstanceCache 是在创建其他bean的时候缓存了一下 FactoryBean。
// factoryBeanInstanceCache 是在创建其他bean的时候缓存了一下 FactoryBean。
if
(
mbd
.
isSingleton
())
{
if
(
mbd
.
isSingleton
())
{
//
TODO: 2022/8/3 什么时候会加缓存?不是很理解这个东西的作用
//
FactoryBean 的beanName -> FactoryBean 的 BeanWrapper
instanceWrapper
=
this
.
factoryBeanInstanceCache
.
remove
(
beanName
);
instanceWrapper
=
this
.
factoryBeanInstanceCache
.
remove
(
beanName
);
}
}
// 如果没有缓存,则重新创建
// 如果没有缓存,则重新创建
...
@@ -638,12 +638,15 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
...
@@ -638,12 +638,15 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
if
(
earlySingletonExposure
)
{
if
(
earlySingletonExposure
)
{
Object
earlySingletonReference
=
getSingleton
(
beanName
,
false
);
Object
earlySingletonReference
=
getSingleton
(
beanName
,
false
);
//
只有在检测到循环依赖的情况下才会不为空
//
前面属性都已经装配完毕,自己出现在了二级缓存中,一定是循环依赖的时候,被从三级缓存中拿到了二级缓存中
if
(
earlySingletonReference
!=
null
)
{
if
(
earlySingletonReference
!=
null
)
{
// 如果传入的对象等于原始对象,那么直接把aop对象向原始对象赋值
// 若exposedObject在增强方法中没有被改变。(没有增强)
// 若exposedObject在增强方法中没有被改变。(没有增强)
// 如果缓存的对象 exposedObject == bean,直接赋值之前暴露出来的bean
if
(
exposedObject
==
bean
)
{
if
(
exposedObject
==
bean
)
{
exposedObject
=
earlySingletonReference
;
exposedObject
=
earlySingletonReference
;
}
}
// 如果提前暴露的对象和经过了完整的生命周期后的对象不相等
else
if
(!
this
.
allowRawInjectionDespiteWrapping
&&
hasDependentBean
(
beanName
))
{
else
if
(!
this
.
allowRawInjectionDespiteWrapping
&&
hasDependentBean
(
beanName
))
{
String
[]
dependentBeans
=
getDependentBeans
(
beanName
);
String
[]
dependentBeans
=
getDependentBeans
(
beanName
);
Set
<
String
>
actualDependentBeans
=
new
LinkedHashSet
<>(
dependentBeans
.
length
);
Set
<
String
>
actualDependentBeans
=
new
LinkedHashSet
<>(
dependentBeans
.
length
);
...
@@ -1204,7 +1207,9 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
...
@@ -1204,7 +1207,9 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
// 但是 bean 的构造函数可能有多个,需要确定使用哪一个。
// 但是 bean 的构造函数可能有多个,需要确定使用哪一个。
// 这里实际上是一个缓存,resolved 表示构造函数是否已经解析完成;autowireNecessary 表示是否需要自动装配
// 这里实际上是一个缓存,resolved 表示构造函数是否已经解析完成;autowireNecessary 表示是否需要自动装配
// Shortcut when re-creating the same bean...
// Shortcut when re-creating the same bean...
// 是否已经完成解析
boolean
resolved
=
false
;
boolean
resolved
=
false
;
// 标志构造函数参数是否解析完成
boolean
autowireNecessary
=
false
;
boolean
autowireNecessary
=
false
;
if
(
args
==
null
)
{
if
(
args
==
null
)
{
synchronized
(
mbd
.
constructorArgumentLock
)
{
synchronized
(
mbd
.
constructorArgumentLock
)
{
...
@@ -1416,7 +1421,6 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
...
@@ -1416,7 +1421,6 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
*/
*/
@SuppressWarnings
(
"deprecation"
)
// for postProcessPropertyValues
@SuppressWarnings
(
"deprecation"
)
// for postProcessPropertyValues
protected
void
populateBean
(
String
beanName
,
RootBeanDefinition
mbd
,
@Nullable
BeanWrapper
bw
)
{
protected
void
populateBean
(
String
beanName
,
RootBeanDefinition
mbd
,
@Nullable
BeanWrapper
bw
)
{
// 标记了@Autowired
if
(
bw
==
null
)
{
if
(
bw
==
null
)
{
if
(
mbd
.
hasPropertyValues
())
{
if
(
mbd
.
hasPropertyValues
())
{
throw
new
BeanCreationException
(
throw
new
BeanCreationException
(
...
@@ -1431,8 +1435,8 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
...
@@ -1431,8 +1435,8 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
// Give any InstantiationAwareBeanPostProcessors the opportunity to modify the
// Give any InstantiationAwareBeanPostProcessors the opportunity to modify the
// state of the bean before properties are set. This can be used, for example,
// state of the bean before properties are set. This can be used, for example,
// to support styles of field injection.
// to support styles of field injection.
// 给
InstantiationAwareBeanPostProcessors
最后一次机会在属性注入前修改Bean的属性值
// 给
InstantiationAwareBeanPostProcessors
最后一次机会在属性注入前修改Bean的属性值
// 具体通过调用
postProcessAfterInstantiation
方法,如果调用返回false,表示不必继续进行依赖注入,直接返回
// 具体通过调用
postProcessAfterInstantiation
方法,如果调用返回false,表示不必继续进行依赖注入,直接返回
if
(!
mbd
.
isSynthetic
()
&&
hasInstantiationAwareBeanPostProcessors
())
{
if
(!
mbd
.
isSynthetic
()
&&
hasInstantiationAwareBeanPostProcessors
())
{
for
(
InstantiationAwareBeanPostProcessor
bp
:
getBeanPostProcessorCache
().
instantiationAware
)
{
for
(
InstantiationAwareBeanPostProcessor
bp
:
getBeanPostProcessorCache
().
instantiationAware
)
{
// 返回值为是否继续填充bean
// 返回值为是否继续填充bean
...
@@ -1469,7 +1473,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
...
@@ -1469,7 +1473,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
pvs
=
mbd
.
getPropertyValues
();
pvs
=
mbd
.
getPropertyValues
();
}
}
// 3. 成员变量的注入
// 3. 成员变量的注入
// 调用了InstantiationAwareBeanPostProcessor.postProcessProperties 方法
// 调用了
InstantiationAwareBeanPostProcessor.postProcessProperties 方法
// 和 postProcessPropertyValues 方法 来进行设值后处理
// 和 postProcessPropertyValues 方法 来进行设值后处理
for
(
InstantiationAwareBeanPostProcessor
bp
:
getBeanPostProcessorCache
().
instantiationAware
)
{
for
(
InstantiationAwareBeanPostProcessor
bp
:
getBeanPostProcessorCache
().
instantiationAware
)
{
PropertyValues
pvsToUse
=
bp
.
postProcessProperties
(
pvs
,
bw
.
getWrappedInstance
(),
beanName
);
PropertyValues
pvsToUse
=
bp
.
postProcessProperties
(
pvs
,
bw
.
getWrappedInstance
(),
beanName
);
...
@@ -1565,7 +1569,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
...
@@ -1565,7 +1569,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
// Do not allow eager init for type matching in case of a prioritized post-processor.
// Do not allow eager init for type matching in case of a prioritized post-processor.
boolean
eager
=
!(
bw
.
getWrappedInstance
()
instanceof
PriorityOrdered
);
boolean
eager
=
!(
bw
.
getWrappedInstance
()
instanceof
PriorityOrdered
);
DependencyDescriptor
desc
=
new
AutowireByTypeDependencyDescriptor
(
methodParam
,
eager
);
DependencyDescriptor
desc
=
new
AutowireByTypeDependencyDescriptor
(
methodParam
,
eager
);
// 解析指定beanName 的属性所匹配的值,并把解析到的属性名存储在 autowiredBeanNames 中
// 解析指定
beanName 的属性所匹配的值,并把解析到的属性名存储在 autowiredBeanNames 中
// 当属性存在多个封装bean时,如 @Autowired List<Bean> beans,会找到所有的匹配Bean 类型的bean并将其注入。
// 当属性存在多个封装bean时,如 @Autowired List<Bean> beans,会找到所有的匹配Bean 类型的bean并将其注入。
// 这里的返回值是真正的需要注入的属性, autowiredBeanNames 是需要注入的属性(可能是集合)的names
// 这里的返回值是真正的需要注入的属性, autowiredBeanNames 是需要注入的属性(可能是集合)的names
Object
autowiredArgument
=
resolveDependency
(
desc
,
beanName
,
autowiredBeanNames
,
converter
);
Object
autowiredArgument
=
resolveDependency
(
desc
,
beanName
,
autowiredBeanNames
,
converter
);
...
...
spring-framework-main/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java
View file @
94e1e9e0
...
@@ -265,7 +265,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
...
@@ -265,7 +265,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
logger
.
trace
(
"Returning cached instance of singleton bean '"
+
beanName
+
"'"
);
logger
.
trace
(
"Returning cached instance of singleton bean '"
+
beanName
+
"'"
);
}
}
}
}
// 返回对应的实例,有时候在诸如
FactoryBean
的情况下,并不是返回实力本身,而是返回指定方法返回的实例
// 返回对应的实例,有时候在诸如
FactoryBean
的情况下,并不是返回实力本身,而是返回指定方法返回的实例
beanInstance
=
getObjectForBeanInstance
(
sharedInstance
,
name
,
beanName
,
null
);
beanInstance
=
getObjectForBeanInstance
(
sharedInstance
,
name
,
beanName
,
null
);
}
}
...
@@ -336,7 +336,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
...
@@ -336,7 +336,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
// 缓存依赖调用,注意这里传入的key是被依赖的bean名称
// 缓存依赖调用,注意这里传入的key是被依赖的bean名称
registerDependentBean
(
dep
,
beanName
);
registerDependentBean
(
dep
,
beanName
);
try
{
try
{
//递归调用getBean方法,注册Bean之间的依赖(如C需要晚于B初始化,而B需要晚于A初始化)
//
递归调用getBean方法,注册Bean之间的依赖(如C需要晚于B初始化,而B需要晚于A初始化)
getBean
(
dep
);
getBean
(
dep
);
}
}
catch
(
NoSuchBeanDefinitionException
ex
)
{
catch
(
NoSuchBeanDefinitionException
ex
)
{
...
@@ -349,7 +349,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
...
@@ -349,7 +349,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
//如果BeanDefinition为单例
//如果BeanDefinition为单例
// Create bean instance.
// Create bean instance.
if
(
mbd
.
isSingleton
())
{
if
(
mbd
.
isSingleton
())
{
// 创建Bean实例对象,并且注册给
所
依赖的对象
// 创建Bean实例对象,并且注册给依赖的对象
sharedInstance
=
getSingleton
(
beanName
,
()
->
{
sharedInstance
=
getSingleton
(
beanName
,
()
->
{
try
{
try
{
return
createBean
(
beanName
,
mbd
,
args
);
return
createBean
(
beanName
,
mbd
,
args
);
...
@@ -1804,7 +1804,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
...
@@ -1804,7 +1804,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
Object
beanInstance
,
String
name
,
String
beanName
,
@Nullable
RootBeanDefinition
mbd
)
{
Object
beanInstance
,
String
name
,
String
beanName
,
@Nullable
RootBeanDefinition
mbd
)
{
// Don't let calling code try to dereference the factory if the bean isn't a factory.
// Don't let calling code try to dereference the factory if the bean isn't a factory.
// 整个这个判断的意思是说,如果要获取的bean是
FactoryBean的引用,但是beanInstance不是FactoryBean
的就抛异常
// 整个这个判断的意思是说,如果要获取的bean是
FactoryBean 的引用,但是 beanInstance 不是 FactoryBean
的就抛异常
// 1. 验证: 判断输入的bean的name是否是FactoryBean相关的BeanName(前缀是&)
// 1. 验证: 判断输入的bean的name是否是FactoryBean相关的BeanName(前缀是&)
...
...
spring-framework-main/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java
View file @
94e1e9e0
...
@@ -343,7 +343,7 @@ class ConstructorResolver {
...
@@ -343,7 +343,7 @@ class ConstructorResolver {
"Could not resolve matching constructor on bean class ["
+
mbd
.
getBeanClassName
()
+
"] "
+
"Could not resolve matching constructor on bean class ["
+
mbd
.
getBeanClassName
()
+
"] "
+
"(hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)"
);
"(hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)"
);
}
}
// 如果ambiguousConstructors 不为空说明有多个构造函数可适配,并且 如果不允许多个存在,则抛出异常
// 如果
ambiguousConstructors 不为空说明有多个构造函数可适配,并且 如果不允许多个存在,则抛出异常
else
if
(
ambiguousConstructors
!=
null
&&
!
mbd
.
isLenientConstructorResolution
())
{
else
if
(
ambiguousConstructors
!=
null
&&
!
mbd
.
isLenientConstructorResolution
())
{
throw
new
BeanCreationException
(
mbd
.
getResourceDescription
(),
beanName
,
throw
new
BeanCreationException
(
mbd
.
getResourceDescription
(),
beanName
,
"Ambiguous constructor matches found on bean class ["
+
mbd
.
getBeanClassName
()
+
"] "
+
"Ambiguous constructor matches found on bean class ["
+
mbd
.
getBeanClassName
()
+
"] "
+
...
...
spring-framework-main/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java
View file @
94e1e9e0
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
package
org
.
springframework
.
beans
.
factory
.
support
;
package
org
.
springframework
.
beans
.
factory
.
support
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
...
@@ -90,7 +92,7 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg
...
@@ -90,7 +92,7 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg
Object
object
=
this
.
factoryBeanObjectCache
.
get
(
beanName
);
Object
object
=
this
.
factoryBeanObjectCache
.
get
(
beanName
);
// 如果缓存中没有
// 如果缓存中没有
if
(
object
==
null
)
{
if
(
object
==
null
)
{
// 激活 FactoryBean<?> 中的 getObject() 方法获取
开发者
// 激活 FactoryBean<?> 中的 getObject() 方法获取
// 定制的初始化逻辑
// 定制的初始化逻辑
object
=
doGetObjectFromFactoryBean
(
factory
,
beanName
);
object
=
doGetObjectFromFactoryBean
(
factory
,
beanName
);
// Only post-process and store if not put there already during getObject() call above
// Only post-process and store if not put there already during getObject() call above
...
@@ -108,7 +110,7 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg
...
@@ -108,7 +110,7 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg
}
}
beforeSingletonCreation
(
beanName
);
beforeSingletonCreation
(
beanName
);
try
{
try
{
// TODO: 2022/8/2 BeanPostProcessor的
后置处理器postProcessAfterInitialization,还没学到
// TODO: 2022/8/2 BeanPostProcessor的
前置处理器不使用吗
object
=
postProcessObjectFromFactoryBean
(
object
,
beanName
);
object
=
postProcessObjectFromFactoryBean
(
object
,
beanName
);
}
}
catch
(
Throwable
ex
)
{
catch
(
Throwable
ex
)
{
...
...
spring-framework-main/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java
View file @
94e1e9e0
...
@@ -741,7 +741,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
...
@@ -741,7 +741,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
// Tell the internal bean factory to use the context's class loader etc.
// Tell the internal bean factory to use the context's class loader etc.
// 设置 BeanFactory 的 ClassLoader 为当前 context 的 classLoader
// 设置 BeanFactory 的 ClassLoader 为当前 context 的 classLoader
beanFactory
.
setBeanClassLoader
(
getClassLoader
());
beanFactory
.
setBeanClassLoader
(
getClassLoader
());
// 设置 BeanFactory 的表达式处理器(SpE),Spring3增加
// 设置 BeanFactory 的表达式处理器(SpE
L
),Spring3增加
if
(!
shouldIgnoreSpel
)
{
if
(!
shouldIgnoreSpel
)
{
beanFactory
.
setBeanExpressionResolver
(
new
StandardBeanExpressionResolver
(
beanFactory
.
getBeanClassLoader
()));
beanFactory
.
setBeanExpressionResolver
(
new
StandardBeanExpressionResolver
(
beanFactory
.
getBeanClassLoader
()));
}
}
...
@@ -990,7 +990,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
...
@@ -990,7 +990,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
}
}
// Initialize LoadTimeWeaverAware beans early to allow for registering their transformers early.
// Initialize LoadTimeWeaverAware beans early to allow for registering their transformers early.
// 3.初始化LoadTimeWeaverAware Bean实例对象
// 3.初始化
LoadTimeWeaverAware Bean实例对象
String
[]
weaverAwareNames
=
beanFactory
.
getBeanNamesForType
(
LoadTimeWeaverAware
.
class
,
false
,
false
);
String
[]
weaverAwareNames
=
beanFactory
.
getBeanNamesForType
(
LoadTimeWeaverAware
.
class
,
false
,
false
);
for
(
String
weaverAwareName
:
weaverAwareNames
)
{
for
(
String
weaverAwareName
:
weaverAwareNames
)
{
getBean
(
weaverAwareName
);
getBean
(
weaverAwareName
);
...
...
spring-framework-main/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java
View file @
94e1e9e0
...
@@ -139,7 +139,7 @@ final class PostProcessorRegistrationDelegate {
...
@@ -139,7 +139,7 @@ final class PostProcessorRegistrationDelegate {
// Next, invoke the BeanDefinitionRegistryPostProcessors that implement Ordered.
// Next, invoke the BeanDefinitionRegistryPostProcessors that implement Ordered.
// 4.调用所有实现了 Ordered 接口的 BeanDefinitionRegistryPostProcessor 实现类(过程跟上面的步骤3基本一样)
// 4.调用所有实现了 Ordered 接口的 BeanDefinitionRegistryPostProcessor 实现类(过程跟上面的步骤3基本一样)
// 找出所有实现 BeanDefinitionRegistryPostProcessor 接口的类,
// 找出所有实现 BeanDefinitionRegistryPostProcessor 接口的类,
// 这边重复查找是因为执行完上面的BeanDefinitionRegistryPostProcessor,
// 这边重复查找是因为执行完上面的
BeanDefinitionRegistryPostProcessor,
// 可能会新增了其他的BeanDefinitionRegistryPostProcessor, 因此需要重新查找
// 可能会新增了其他的BeanDefinitionRegistryPostProcessor, 因此需要重新查找
postProcessorNames
=
beanFactory
.
getBeanNamesForType
(
BeanDefinitionRegistryPostProcessor
.
class
,
true
,
false
);
postProcessorNames
=
beanFactory
.
getBeanNamesForType
(
BeanDefinitionRegistryPostProcessor
.
class
,
true
,
false
);
for
(
String
ppName
:
postProcessorNames
)
{
for
(
String
ppName
:
postProcessorNames
)
{
...
@@ -190,7 +190,7 @@ final class PostProcessorRegistrationDelegate {
...
@@ -190,7 +190,7 @@ final class PostProcessorRegistrationDelegate {
// uninitialized to let the bean factory post-processors apply to them!
// uninitialized to let the bean factory post-processors apply to them!
// 到这里, 入参 beanFactoryPostProcessors 和容器中的所有 BeanDefinitionRegistryPostProcessor 已经全部处理完毕,
// 到这里, 入参 beanFactoryPostProcessors 和容器中的所有 BeanDefinitionRegistryPostProcessor 已经全部处理完毕,
// 下面开始处理容器中的所有 BeanFactoryPostProcessor
// 下面开始处理容器中的所有 BeanFactoryPostProcessor
// 8.找出所有实现
BeanFactoryPostProcessor
接口的类
// 8.找出所有实现
BeanFactoryPostProcessor
接口的类
String
[]
postProcessorNames
=
String
[]
postProcessorNames
=
beanFactory
.
getBeanNamesForType
(
BeanFactoryPostProcessor
.
class
,
true
,
false
);
beanFactory
.
getBeanNamesForType
(
BeanFactoryPostProcessor
.
class
,
true
,
false
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment