Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
e64c6dfa
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
GitCode(gitcode.net)2024年7月9日维护升级公告
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
e64c6dfa
编写于
8月 06, 2018
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MergedBeanDefinitionPostProcessors clear internal caches on bean reset
Issue: SPR-17126
上级
69c6a40c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
38 addition
and
5 deletion
+38
-5
spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java
...tory/annotation/AutowiredAnnotationBeanPostProcessor.java
+6
-0
spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java
...s/factory/support/AbstractAutowireCapableBeanFactory.java
+4
-4
spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java
...ork/beans/factory/support/DefaultListableBeanFactory.java
+8
-0
spring-beans/src/main/java/org/springframework/beans/factory/support/MergedBeanDefinitionPostProcessor.java
...ns/factory/support/MergedBeanDefinitionPostProcessor.java
+10
-1
spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java
...context/annotation/CommonAnnotationBeanPostProcessor.java
+5
-0
spring-orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java
...m/jpa/support/PersistenceAnnotationBeanPostProcessor.java
+5
-0
未找到文件。
spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java
浏览文件 @
e64c6dfa
...
...
@@ -233,6 +233,12 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
metadata
.
checkConfigMembers
(
beanDefinition
);
}
@Override
public
void
resetBeanDefinition
(
String
beanName
)
{
this
.
lookupMethodsChecked
.
remove
(
beanName
);
this
.
injectionMetadataCache
.
remove
(
beanName
);
}
@Override
@Nullable
public
Constructor
<?>[]
determineCandidateConstructors
(
Class
<?>
beanClass
,
final
String
beanName
)
...
...
spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java
浏览文件 @
e64c6dfa
...
...
@@ -415,8 +415,8 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
throws
BeansException
{
Object
result
=
existingBean
;
for
(
BeanPostProcessor
beanP
rocessor
:
getBeanPostProcessors
())
{
Object
current
=
beanP
rocessor
.
postProcessBeforeInitialization
(
result
,
beanName
);
for
(
BeanPostProcessor
p
rocessor
:
getBeanPostProcessors
())
{
Object
current
=
p
rocessor
.
postProcessBeforeInitialization
(
result
,
beanName
);
if
(
current
==
null
)
{
return
result
;
}
...
...
@@ -430,8 +430,8 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
throws
BeansException
{
Object
result
=
existingBean
;
for
(
BeanPostProcessor
beanP
rocessor
:
getBeanPostProcessors
())
{
Object
current
=
beanP
rocessor
.
postProcessAfterInitialization
(
result
,
beanName
);
for
(
BeanPostProcessor
p
rocessor
:
getBeanPostProcessors
())
{
Object
current
=
p
rocessor
.
postProcessAfterInitialization
(
result
,
beanName
);
if
(
current
==
null
)
{
return
result
;
}
...
...
spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java
浏览文件 @
e64c6dfa
...
...
@@ -65,6 +65,7 @@ import org.springframework.beans.factory.SmartInitializingSingleton;
import
org.springframework.beans.factory.config.AutowireCapableBeanFactory
;
import
org.springframework.beans.factory.config.BeanDefinition
;
import
org.springframework.beans.factory.config.BeanDefinitionHolder
;
import
org.springframework.beans.factory.config.BeanPostProcessor
;
import
org.springframework.beans.factory.config.ConfigurableBeanFactory
;
import
org.springframework.beans.factory.config.ConfigurableListableBeanFactory
;
import
org.springframework.beans.factory.config.DependencyDescriptor
;
...
...
@@ -969,6 +970,13 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
// (e.g. the default StaticMessageSource in a StaticApplicationContext).
destroySingleton
(
beanName
);
// Notify all post-processors that the specified bean definition has been reset.
for
(
BeanPostProcessor
processor
:
getBeanPostProcessors
())
{
if
(
processor
instanceof
MergedBeanDefinitionPostProcessor
)
{
((
MergedBeanDefinitionPostProcessor
)
processor
).
resetBeanDefinition
(
beanName
);
}
}
// Reset all bean definitions that have the given bean as parent (recursively).
for
(
String
bdName
:
this
.
beanDefinitionNames
)
{
if
(!
beanName
.
equals
(
bdName
))
{
...
...
spring-beans/src/main/java/org/springframework/beans/factory/support/MergedBeanDefinitionPostProcessor.java
浏览文件 @
e64c6dfa
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -45,4 +45,13 @@ public interface MergedBeanDefinitionPostProcessor extends BeanPostProcessor {
*/
void
postProcessMergedBeanDefinition
(
RootBeanDefinition
beanDefinition
,
Class
<?>
beanType
,
String
beanName
);
/**
* A notification that the bean definition for the specified name has been reset,
* and that this post-processor should clear any metadata for the affected bean.
* @param beanName the name of the bean
* @since 5.1
*/
default
void
resetBeanDefinition
(
String
beanName
)
{
}
}
spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java
浏览文件 @
e64c6dfa
...
...
@@ -299,6 +299,11 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
metadata
.
checkConfigMembers
(
beanDefinition
);
}
@Override
public
void
resetBeanDefinition
(
String
beanName
)
{
this
.
injectionMetadataCache
.
remove
(
beanName
);
}
@Override
public
Object
postProcessBeforeInstantiation
(
Class
<?>
beanClass
,
String
beanName
)
{
return
null
;
...
...
spring-orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java
浏览文件 @
e64c6dfa
...
...
@@ -334,6 +334,11 @@ public class PersistenceAnnotationBeanPostProcessor
metadata
.
checkConfigMembers
(
beanDefinition
);
}
@Override
public
void
resetBeanDefinition
(
String
beanName
)
{
this
.
injectionMetadataCache
.
remove
(
beanName
);
}
@Override
public
Object
postProcessBeforeInstantiation
(
Class
<?>
beanClass
,
String
beanName
)
{
return
null
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录