Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
26a4aef4
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,发现更多精彩内容 >>
提交
26a4aef4
编写于
12月 29, 2016
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
(cherry picked from commit
fc629bb5
)
上级
050f2c74
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
46 addition
and
54 deletion
+46
-54
spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java
...ork/aop/framework/autoproxy/AbstractAutoProxyCreator.java
+24
-25
spring-beans/src/main/java/org/springframework/beans/factory/support/MergedBeanDefinitionPostProcessor.java
...ns/factory/support/MergedBeanDefinitionPostProcessor.java
+9
-9
spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java
...k/context/annotation/ConfigurationClassPostProcessor.java
+0
-5
spring-jms/src/main/java/org/springframework/jms/config/JmsListenerEndpointRegistrar.java
...ingframework/jms/config/JmsListenerEndpointRegistrar.java
+1
-2
src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java
.../aop/config/AopNamespaceHandlerScopeIntegrationTests.java
+12
-13
未找到文件。
spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java
浏览文件 @
26a4aef4
...
...
@@ -55,26 +55,25 @@ import org.springframework.util.StringUtils;
* before invoking the bean itself.
*
* <p>This class distinguishes between "common" interceptors: shared for all proxies it
* creates, and "specific" interceptors: unique per bean instance. There need not
*
be any common interceptors. If there are, they are set using the interceptorNames
*
property. As with ProxyFactoryBean, interceptors names in the current factory
*
are used rather than bean references to allow correct handling of prototype
* advisors and interceptors: for example, to support stateful mixins.
* Any advice type is supported for
"interceptorNames"
entries.
* creates, and "specific" interceptors: unique per bean instance. There need not
be any
*
common interceptors. If there are, they are set using the interceptorNames property.
*
As with {@link org.springframework.aop.framework.ProxyFactoryBean}, interceptors names
*
in the current factory are used rather than bean references to allow correct handling
*
of prototype
advisors and interceptors: for example, to support stateful mixins.
* Any advice type is supported for
{@link #setInterceptorNames "interceptorNames"}
entries.
*
* <p>Such auto-proxying is particularly useful if there's a large number of beans that
* need to be wrapped with similar proxies, i.e. delegating to the same interceptors.
* Instead of x repetitive proxy definitions for x target beans, you can register
* one single such post processor with the bean factory to achieve the same effect.
*
* <p>Subclasses can apply any strategy to decide if a bean is to be proxied,
* e.g. by type, by name, by definition details, etc. They can also return
* additional interceptors that should just be applied to the specific bean
* instance. The default concrete implementation is BeanNameAutoProxyCreator,
* identifying the beans to be proxied via a list of bean names.
* <p>Subclasses can apply any strategy to decide if a bean is to be proxied, e.g. by type,
* by name, by definition details, etc. They can also return additional interceptors that
* should just be applied to the specific bean instance. A simple concrete implementation is
* {@link BeanNameAutoProxyCreator}, identifying the beans to be proxied via given names.
*
* <p>Any number of {@link TargetSourceCreator} implementations can be used to create
* a custom target source
-
for example, to pool prototype objects. Auto-proxying will
* a custom target source
:
for example, to pool prototype objects. Auto-proxying will
* occur even if there is no advice, as long as a TargetSourceCreator specifies a custom
* {@link org.springframework.aop.TargetSource}. If there are no TargetSourceCreators set,
* or if none matches, a {@link org.springframework.aop.target.SingletonTargetSource}
...
...
@@ -156,8 +155,8 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
}
/**
* Specify the
AdvisorAdapterRegistry
to use.
*
Default is the global AdvisorAdapterRegistry
.
* Specify the
{@link AdvisorAdapterRegistry}
to use.
*
<p>Default is the global {@link AdvisorAdapterRegistry}
.
* @see org.springframework.aop.framework.adapter.GlobalAdvisorAdapterRegistry
*/
public
void
setAdvisorAdapterRegistry
(
AdvisorAdapterRegistry
advisorAdapterRegistry
)
{
...
...
@@ -165,18 +164,18 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
}
/**
* Set custom
TargetSourceCreators
to be applied in this order.
* If the list is empty, or they all return null, a
SingletonTargetSource
* Set custom
{@code TargetSourceCreators}
to be applied in this order.
* If the list is empty, or they all return null, a
{@link SingletonTargetSource}
* will be created for each bean.
* <p>Note that TargetSourceCreators will kick in even for target beans
* where no advices or advisors have been found. If a
TargetSourceCreator
* returns a
TargetSource
for a specific bean, that bean will be proxied
* where no advices or advisors have been found. If a
{@code TargetSourceCreator}
* returns a
{@link TargetSource}
for a specific bean, that bean will be proxied
* in any case.
* <p>
TargetSourceCreators
can only be invoked if this post processor is used
* in a
BeanFactory, and its BeanFactoryAware callback is us
ed.
* @param targetSourceCreators
list of TargetSourceCreator
.
* Ordering is significant: The
TargetSource
returned from the first matching
*
TargetSourceCreator
(that is, the first that returns non-null) will be used.
* <p>
{@code TargetSourceCreators}
can only be invoked if this post processor is used
* in a
{@link BeanFactory} and its {@link BeanFactoryAware} callback is trigger
ed.
* @param targetSourceCreators
the list of {@code TargetSourceCreators}
.
* Ordering is significant: The
{@code TargetSource}
returned from the first matching
*
{@code TargetSourceCreator}
(that is, the first that returns non-null) will be used.
*/
public
void
setCustomTargetSourceCreators
(
TargetSourceCreator
...
targetSourceCreators
)
{
this
.
customTargetSourceCreators
=
targetSourceCreators
;
...
...
@@ -207,8 +206,8 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
}
/**
* Return the owning
BeanFactory
.
* May be {@code null}, as this
object
doesn't need to belong to a bean factory.
* Return the owning
{@link BeanFactory}
.
* May be {@code null}, as this
post-processor
doesn't need to belong to a bean factory.
*/
protected
BeanFactory
getBeanFactory
()
{
return
this
.
beanFactory
;
...
...
spring-beans/src/main/java/org/springframework/beans/factory/support/MergedBeanDefinitionPostProcessor.java
浏览文件 @
26a4aef4
/*
* Copyright 2002-20
08
the original author or authors.
* Copyright 2002-20
16
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.
...
...
@@ -20,20 +20,20 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
/**
* Post-processor callback interface for <i>merged</i> bean definitions at runtime.
* {@link BeanPostProcessor} implementations may implement this sub-interface in
*
order to post-process the merged bean definition that the Spring BeanFactory
*
uses to create a specific
bean instance.
* {@link BeanPostProcessor} implementations may implement this sub-interface in
order
*
to post-process the merged bean definition (a processed copy of the original bean
*
definition) that the Spring {@code BeanFactory} uses to create a
bean instance.
*
* <p>The {@link #postProcessMergedBeanDefinition} method may for example introspect
* the bean definition in order to prepare some cached metadata before post-processing
* actual instances of a bean. It is also allowed to modify the bean definition
* but <i>only</i> for bean definition properties which are actually intended
* for concurrent modification. Basically, this only applies to operations
* defined on the {@link RootBeanDefinition} itself but not to the properties
* of its base classes.
* actual instances of a bean. It is also allowed to modify the bean definition but
* <i>only</i> for definition properties which are actually intended for concurrent
* modification. Essentially, this only applies to operations defined on the
* {@link RootBeanDefinition} itself but not to the properties of its base classes.
*
* @author Juergen Hoeller
* @since 2.5
* @see org.springframework.beans.factory.config.ConfigurableBeanFactory#getMergedBeanDefinition
*/
public
interface
MergedBeanDefinitionPostProcessor
extends
BeanPostProcessor
{
...
...
spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java
浏览文件 @
26a4aef4
...
...
@@ -435,11 +435,6 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
}
return
bean
;
}
@Override
public
Object
postProcessAfterInitialization
(
Object
bean
,
String
beanName
)
{
return
bean
;
}
}
}
spring-jms/src/main/java/org/springframework/jms/config/JmsListenerEndpointRegistrar.java
浏览文件 @
26a4aef4
...
...
@@ -28,8 +28,7 @@ import org.springframework.messaging.handler.annotation.support.MessageHandlerMe
import
org.springframework.util.Assert
;
/**
* Helper bean for registering {@link JmsListenerEndpoint} with
* a {@link JmsListenerEndpointRegistry}.
* Helper bean for registering {@link JmsListenerEndpoint} with a {@link JmsListenerEndpointRegistry}.
*
* @author Stephane Nicoll
* @author Juergen Hoeller
...
...
src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java
浏览文件 @
26a4aef4
/*
* Copyright 2002-201
3
the original author or authors.
* Copyright 2002-201
6
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.
...
...
@@ -16,14 +16,9 @@
package
org.springframework.aop.config
;
import
static
java
.
lang
.
String
.
format
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertSame
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.springframework.aop.framework.Advised
;
import
org.springframework.aop.support.AopUtils
;
import
org.springframework.context.ApplicationContext
;
...
...
@@ -37,31 +32,35 @@ import org.springframework.web.context.request.RequestContextHolder;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
org.springframework.web.context.support.XmlWebApplicationContext
;
import
static
java
.
lang
.
String
.
format
;
import
static
org
.
junit
.
Assert
.*;
/**
* Integration tests for scoped proxy use in conjunction with aop: namespace.
* Deemed an integration test because .web mocks and application contexts are required.
*
* @see org.springframework.aop.config.AopNamespaceHandlerTests
*
* @author Rob Harrop
* @author Juergen Hoeller
* @author Chris Beams
* @see org.springframework.aop.config.AopNamespaceHandlerTests
*/
public
final
class
AopNamespaceHandlerScopeIntegrationTests
{
public
class
AopNamespaceHandlerScopeIntegrationTests
{
private
static
final
String
C
LASSNAME
=
AopNamespaceHandlerScopeIntegrationTests
.
class
.
getName
();
private
static
final
String
CONTEXT
=
format
(
"classpath:%s-context.xml"
,
ClassUtils
.
convertClassNameToResourcePath
(
CLASSNAME
));
private
static
final
String
C
ONTEXT
=
format
(
"classpath:%s-context.xml"
,
ClassUtils
.
convertClassNameToResourcePath
(
AopNamespaceHandlerScopeIntegrationTests
.
class
.
getName
()
));
private
ApplicationContext
context
;
@Before
public
void
setUp
()
{
XmlWebApplicationContext
wac
=
new
XmlWebApplicationContext
();
wac
.
setConfigLocations
(
new
String
[]
{
CONTEXT
}
);
wac
.
setConfigLocations
(
CONTEXT
);
wac
.
refresh
();
this
.
context
=
wac
;
}
@Test
public
void
testSingletonScoping
()
throws
Exception
{
ITestBean
scoped
=
(
ITestBean
)
this
.
context
.
getBean
(
"singletonScoped"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录