Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
5fcfe0fa
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,发现更多精彩内容 >>
提交
5fcfe0fa
编写于
7月 18, 2018
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
cab35aa7
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
42 addition
and
28 deletion
+42
-28
spring-aop/src/main/java/org/springframework/aop/framework/DefaultAdvisorChainFactory.java
...ngframework/aop/framework/DefaultAdvisorChainFactory.java
+21
-11
spring-aop/src/main/java/org/springframework/aop/framework/adapter/AdvisorAdapterRegistry.java
...amework/aop/framework/adapter/AdvisorAdapterRegistry.java
+10
-11
spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/BeanFactoryJCacheOperationSourceAdvisor.java
.../interceptor/BeanFactoryJCacheOperationSourceAdvisor.java
+1
-0
spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/DefaultCacheKeyInvocationContext.java
.../jcache/interceptor/DefaultCacheKeyInvocationContext.java
+2
-2
spring-context/src/main/java/org/springframework/validation/DataBinder.java
.../main/java/org/springframework/validation/DataBinder.java
+1
-1
spring-web/src/main/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessor.java
.../web/method/annotation/ModelAttributeMethodProcessor.java
+7
-3
未找到文件。
spring-aop/src/main/java/org/springframework/aop/framework/DefaultAdvisorChainFactory.java
浏览文件 @
5fcfe0fa
/*
* 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.
...
...
@@ -27,11 +27,11 @@ import org.aopalliance.intercept.MethodInterceptor;
import
org.springframework.aop.Advisor
;
import
org.springframework.aop.IntroductionAdvisor
;
import
org.springframework.aop.IntroductionAwareMethodMatcher
;
import
org.springframework.aop.MethodMatcher
;
import
org.springframework.aop.PointcutAdvisor
;
import
org.springframework.aop.framework.adapter.AdvisorAdapterRegistry
;
import
org.springframework.aop.framework.adapter.GlobalAdvisorAdapterRegistry
;
import
org.springframework.aop.support.MethodMatchers
;
import
org.springframework.lang.Nullable
;
/**
...
...
@@ -53,19 +53,30 @@ public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializ
// This is somewhat tricky... We have to process introductions first,
// but we need to preserve order in the ultimate list.
List
<
Object
>
interceptorList
=
new
ArrayList
<>(
config
.
getAdvisors
().
length
);
Class
<?>
actualClass
=
(
targetClass
!=
null
?
targetClass
:
method
.
getDeclaringClass
());
boolean
hasIntroductions
=
hasMatchingIntroductions
(
config
,
actualClass
);
AdvisorAdapterRegistry
registry
=
GlobalAdvisorAdapterRegistry
.
getInstance
();
Advisor
[]
advisors
=
config
.
getAdvisors
();
List
<
Object
>
interceptorList
=
new
ArrayList
<>(
advisors
.
length
);
Class
<?>
actualClass
=
(
targetClass
!=
null
?
targetClass
:
method
.
getDeclaringClass
());
Boolean
hasIntroductions
=
null
;
for
(
Advisor
advisor
:
config
.
getAdvisors
()
)
{
for
(
Advisor
advisor
:
advisors
)
{
if
(
advisor
instanceof
PointcutAdvisor
)
{
// Add it conditionally.
PointcutAdvisor
pointcutAdvisor
=
(
PointcutAdvisor
)
advisor
;
if
(
config
.
isPreFiltered
()
||
pointcutAdvisor
.
getPointcut
().
getClassFilter
().
matches
(
actualClass
))
{
MethodInterceptor
[]
interceptors
=
registry
.
getInterceptors
(
advisor
);
MethodMatcher
mm
=
pointcutAdvisor
.
getPointcut
().
getMethodMatcher
();
if
(
MethodMatchers
.
matches
(
mm
,
method
,
actualClass
,
hasIntroductions
))
{
boolean
match
;
if
(
mm
instanceof
IntroductionAwareMethodMatcher
)
{
if
(
hasIntroductions
==
null
)
{
hasIntroductions
=
hasMatchingIntroductions
(
advisors
,
actualClass
);
}
match
=
((
IntroductionAwareMethodMatcher
)
mm
).
matches
(
method
,
targetClass
,
hasIntroductions
);
}
else
{
match
=
mm
.
matches
(
method
,
targetClass
);
}
if
(
match
)
{
MethodInterceptor
[]
interceptors
=
registry
.
getInterceptors
(
advisor
);
if
(
mm
.
isRuntime
())
{
// Creating a new object instance in the getInterceptors() method
// isn't a problem as we normally cache created chains.
...
...
@@ -98,9 +109,8 @@ public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializ
/**
* Determine whether the Advisors contain matching introductions.
*/
private
static
boolean
hasMatchingIntroductions
(
Advised
config
,
Class
<?>
actualClass
)
{
for
(
int
i
=
0
;
i
<
config
.
getAdvisors
().
length
;
i
++)
{
Advisor
advisor
=
config
.
getAdvisors
()[
i
];
private
static
boolean
hasMatchingIntroductions
(
Advisor
[]
advisors
,
Class
<?>
actualClass
)
{
for
(
Advisor
advisor
:
advisors
)
{
if
(
advisor
instanceof
IntroductionAdvisor
)
{
IntroductionAdvisor
ia
=
(
IntroductionAdvisor
)
advisor
;
if
(
ia
.
getClassFilter
().
matches
(
actualClass
))
{
...
...
spring-aop/src/main/java/org/springframework/aop/framework/adapter/AdvisorAdapterRegistry.java
浏览文件 @
5fcfe0fa
...
...
@@ -31,15 +31,15 @@ import org.springframework.aop.Advisor;
public
interface
AdvisorAdapterRegistry
{
/**
* Return an
Advisor
wrapping the given advice.
* Return an
{@link Advisor}
wrapping the given advice.
* <p>Should by default at least support
* {@link org.aopalliance.intercept.MethodInterceptor},
* {@link org.springframework.aop.MethodBeforeAdvice},
* {@link org.springframework.aop.AfterReturningAdvice},
* {@link org.springframework.aop.ThrowsAdvice}.
* @param advice object that should be an advice
* @return an Advisor wrapping the given advice
. Never returns {@code null}.
*
If the advice parameter is an Advisor, return it.
* @param advice
an
object that should be an advice
* @return an Advisor wrapping the given advice
(never {@code null};
*
if the advice parameter is an Advisor, it is to be returned as-is)
* @throws UnknownAdviceTypeException if no registered advisor adapter
* can wrap the supposed advice
*/
...
...
@@ -48,21 +48,20 @@ public interface AdvisorAdapterRegistry {
/**
* Return an array of AOP Alliance MethodInterceptors to allow use of the
* given Advisor in an interception-based framework.
* <p>Don't worry about the pointcut associated with the
Advisor,
*
if it's a PointcutAdvisor
: just return an interceptor.
* <p>Don't worry about the pointcut associated with the
{@link Advisor}, if it is
*
a {@link org.springframework.aop.PointcutAdvisor}
: just return an interceptor.
* @param advisor the Advisor to find an interceptor for
* @return an array of MethodInterceptors to expose this Advisor's behavior
* @throws UnknownAdviceTypeException if the Advisor type is
* not understood by any registered AdvisorAdapter
.
* not understood by any registered AdvisorAdapter
*/
MethodInterceptor
[]
getInterceptors
(
Advisor
advisor
)
throws
UnknownAdviceTypeException
;
/**
* Register the given
AdvisorAdapter
. Note that it is not necessary to register
* Register the given
{@link AdvisorAdapter}
. Note that it is not necessary to register
* adapters for an AOP Alliance Interceptors or Spring Advices: these must be
* automatically recognized by an AdvisorAdapterRegistry implementation.
* @param adapter the AdvisorAdapter that understands a particular Advisor
* or Advice types
* automatically recognized by an {@code AdvisorAdapterRegistry} implementation.
* @param adapter an AdvisorAdapter that understands particular Advisor or Advice types
*/
void
registerAdvisorAdapter
(
AdvisorAdapter
adapter
);
...
...
spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/BeanFactoryJCacheOperationSourceAdvisor.java
浏览文件 @
5fcfe0fa
...
...
@@ -41,6 +41,7 @@ public class BeanFactoryJCacheOperationSourceAdvisor extends AbstractBeanFactory
}
};
/**
* Set the cache operation attribute source which is used to find cache
* attributes. This should usually be identical to the source reference
...
...
spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/DefaultCacheKeyInvocationContext.java
浏览文件 @
5fcfe0fa
...
...
@@ -29,8 +29,8 @@ import org.springframework.lang.Nullable;
* @since 4.1
* @param <A> the annotation type
*/
class
DefaultCacheKeyInvocationContext
<
A
extends
Annotation
>
extends
DefaultCacheInvocationContext
<
A
>
implements
CacheKeyInvocationContext
<
A
>
{
class
DefaultCacheKeyInvocationContext
<
A
extends
Annotation
>
extends
DefaultCacheInvocationContext
<
A
>
implements
CacheKeyInvocationContext
<
A
>
{
private
final
CacheInvocationParameter
[]
keyParameters
;
...
...
spring-context/src/main/java/org/springframework/validation/DataBinder.java
浏览文件 @
5fcfe0fa
...
...
@@ -857,7 +857,7 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
Assert
.
state
(
target
!=
null
,
"No target to validate"
);
BindingResult
bindingResult
=
getBindingResult
();
// Call each validator with the same binding result
for
(
Validator
validator
:
this
.
validators
)
{
for
(
Validator
validator
:
getValidators
()
)
{
validator
.
validate
(
target
,
bindingResult
);
}
}
...
...
spring-web/src/main/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessor.java
浏览文件 @
5fcfe0fa
...
...
@@ -309,8 +309,9 @@ public class ModelAttributeMethodProcessor implements HandlerMethodArgumentResol
for
(
int
i
=
0
;
i
<
paramNames
.
length
;
i
++)
{
String
paramName
=
paramNames
[
i
];
if
(!
failedParams
.
contains
(
paramName
))
{
result
.
recordFieldValue
(
paramName
,
paramTypes
[
i
],
args
[
i
]);
validateValueIfApplicable
(
binder
,
parameter
,
ctor
.
getDeclaringClass
(),
paramName
,
args
[
i
]);
Object
value
=
args
[
i
];
result
.
recordFieldValue
(
paramName
,
paramTypes
[
i
],
value
);
validateValueIfApplicable
(
binder
,
parameter
,
ctor
.
getDeclaringClass
(),
paramName
,
value
);
}
}
throw
new
BindException
(
result
);
...
...
@@ -410,7 +411,10 @@ public class ModelAttributeMethodProcessor implements HandlerMethodArgumentResol
Validated
validatedAnn
=
AnnotationUtils
.
getAnnotation
(
ann
,
Validated
.
class
);
if
(
validatedAnn
!=
null
||
ann
.
annotationType
().
getSimpleName
().
startsWith
(
"Valid"
))
{
Object
hints
=
(
validatedAnn
!=
null
?
validatedAnn
.
value
()
:
AnnotationUtils
.
getValue
(
ann
));
return
(
hints
instanceof
Object
[]
?
(
Object
[])
hints
:
new
Object
[]{
hints
});
if
(
hints
==
null
)
{
return
new
Object
[
0
];
}
return
(
hints
instanceof
Object
[]
?
(
Object
[])
hints
:
new
Object
[]
{
hints
});
}
return
null
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录