Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Meiracle
spring-framework
提交
f329140d
S
spring-framework
项目概览
Meiracle
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
f329140d
编写于
8月 02, 2013
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed ClassFilterAwareUnionMethodMatcher equals implementation
Issue: SPR-10604
上级
9e20a256
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
10 deletion
+32
-10
spring-aop/src/main/java/org/springframework/aop/support/MethodMatchers.java
.../java/org/springframework/aop/support/MethodMatchers.java
+17
-8
spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java
.../org/springframework/aop/support/MethodMatchersTests.java
+15
-2
未找到文件。
spring-aop/src/main/java/org/springframework/aop/support/MethodMatchers.java
浏览文件 @
f329140d
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
3
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.
...
...
@@ -102,8 +102,9 @@ public abstract class MethodMatchers {
@SuppressWarnings
(
"serial"
)
private
static
class
UnionMethodMatcher
implements
IntroductionAwareMethodMatcher
,
Serializable
{
private
MethodMatcher
mm1
;
private
MethodMatcher
mm2
;
private
final
MethodMatcher
mm1
;
private
final
MethodMatcher
mm2
;
public
UnionMethodMatcher
(
MethodMatcher
mm1
,
MethodMatcher
mm2
)
{
Assert
.
notNull
(
mm1
,
"First MethodMatcher must not be null"
);
...
...
@@ -172,6 +173,7 @@ public abstract class MethodMatchers {
private
static
class
ClassFilterAwareUnionMethodMatcher
extends
UnionMethodMatcher
{
private
final
ClassFilter
cf1
;
private
final
ClassFilter
cf2
;
public
ClassFilterAwareUnionMethodMatcher
(
MethodMatcher
mm1
,
ClassFilter
cf1
,
MethodMatcher
mm2
,
ClassFilter
cf2
)
{
...
...
@@ -195,11 +197,17 @@ public abstract class MethodMatchers {
if
(
this
==
other
)
{
return
true
;
}
if
(!
(
other
instanceof
ClassFilterAwareUnionMethodMatc
her
))
{
if
(!
super
.
equals
(
ot
her
))
{
return
false
;
}
ClassFilterAwareUnionMethodMatcher
that
=
(
ClassFilterAwareUnionMethodMatcher
)
other
;
return
(
this
.
cf1
.
equals
(
that
.
cf1
)
&&
this
.
cf2
.
equals
(
that
.
cf2
)
&&
super
.
equals
(
other
));
ClassFilter
otherCf1
=
ClassFilter
.
TRUE
;
ClassFilter
otherCf2
=
ClassFilter
.
TRUE
;
if
(
other
instanceof
ClassFilterAwareUnionMethodMatcher
)
{
ClassFilterAwareUnionMethodMatcher
cfa
=
(
ClassFilterAwareUnionMethodMatcher
)
other
;
otherCf1
=
cfa
.
cf1
;
otherCf2
=
cfa
.
cf2
;
}
return
(
this
.
cf1
.
equals
(
otherCf1
)
&&
this
.
cf2
.
equals
(
otherCf2
));
}
}
...
...
@@ -210,8 +218,9 @@ public abstract class MethodMatchers {
@SuppressWarnings
(
"serial"
)
private
static
class
IntersectionMethodMatcher
implements
IntroductionAwareMethodMatcher
,
Serializable
{
private
MethodMatcher
mm1
;
private
MethodMatcher
mm2
;
private
final
MethodMatcher
mm1
;
private
final
MethodMatcher
mm2
;
public
IntersectionMethodMatcher
(
MethodMatcher
mm1
,
MethodMatcher
mm2
)
{
Assert
.
notNull
(
mm1
,
"First MethodMatcher must not be null"
);
...
...
spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java
浏览文件 @
f329140d
...
...
@@ -43,6 +43,7 @@ public final class MethodMatchersTests {
private
final
Method
IOTHER_ABSQUATULATE
;
public
MethodMatchersTests
()
throws
Exception
{
EXCEPTION_GETMESSAGE
=
Exception
.
class
.
getMethod
(
"getMessage"
,
(
Class
[])
null
);
ITESTBEAN_GETAGE
=
ITestBean
.
class
.
getMethod
(
"getAge"
,
(
Class
[])
null
);
...
...
@@ -50,6 +51,7 @@ public final class MethodMatchersTests {
IOTHER_ABSQUATULATE
=
IOther
.
class
.
getMethod
(
"absquatulate"
,
(
Class
[])
null
);
}
@Test
public
void
testDefaultMatchesAll
()
throws
Exception
{
MethodMatcher
defaultMm
=
MethodMatcher
.
TRUE
;
...
...
@@ -99,23 +101,33 @@ public final class MethodMatchersTests {
assertTrue
(
"Matched setAge method"
,
union
.
matches
(
ITESTBEAN_SETAGE
,
TestBean
.
class
));
assertTrue
(
"Matched getAge method"
,
union
.
matches
(
ITESTBEAN_GETAGE
,
TestBean
.
class
));
assertFalse
(
"Didn't matched absquatulate method"
,
union
.
matches
(
IOTHER_ABSQUATULATE
,
TestBean
.
class
));
}
@Test
public
void
testUnionEquals
()
{
MethodMatcher
first
=
MethodMatchers
.
union
(
MethodMatcher
.
TRUE
,
MethodMatcher
.
TRUE
);
MethodMatcher
second
=
new
ComposablePointcut
(
MethodMatcher
.
TRUE
).
union
(
new
ComposablePointcut
(
MethodMatcher
.
TRUE
)).
getMethodMatcher
();
assertTrue
(
first
.
equals
(
second
));
assertTrue
(
second
.
equals
(
first
));
}
public
static
class
StartsWithMatcher
extends
StaticMethodMatcher
{
private
String
prefix
;
private
final
String
prefix
;
public
StartsWithMatcher
(
String
s
)
{
this
.
prefix
=
s
;
}
@Override
public
boolean
matches
(
Method
m
,
Class
<?>
targetClass
)
{
return
m
.
getName
().
startsWith
(
prefix
);
}
}
private
static
class
TestDynamicMethodMatcherWhichMatches
extends
DynamicMethodMatcher
{
@Override
public
boolean
matches
(
Method
m
,
Class
<?>
targetClass
,
Object
[]
args
)
{
return
true
;
...
...
@@ -123,6 +135,7 @@ public final class MethodMatchersTests {
}
private
static
class
TestDynamicMethodMatcherWhichDoesNotMatch
extends
DynamicMethodMatcher
{
@Override
public
boolean
matches
(
Method
m
,
Class
<?>
targetClass
,
Object
[]
args
)
{
return
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录