Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
27d1ce84
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,体验更适合开发者的 AI 搜索 >>
提交
27d1ce84
编写于
6月 20, 2015
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
fb83e83e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
30 deletion
+30
-30
spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessor.java
...ling/annotation/ScheduledAnnotationBeanPostProcessor.java
+1
-1
spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java
.../org/springframework/core/annotation/AnnotationUtils.java
+17
-17
spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java
...springframework/core/annotation/AnnotationUtilsTests.java
+8
-8
spring-test/src/main/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListener.java
...rk/test/context/jdbc/SqlScriptsTestExecutionListener.java
+4
-4
未找到文件。
spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessor.java
浏览文件 @
27d1ce84
...
...
@@ -224,7 +224,7 @@ public class ScheduledAnnotationBeanPostProcessor implements BeanPostProcessor,
@Override
public
void
doWith
(
Method
method
)
throws
IllegalArgumentException
,
IllegalAccessException
{
for
(
Scheduled
scheduled
:
AnnotationUtils
.
getRepeatableAnnotations
(
method
,
Schedule
s
.
class
,
Scheduled
.
class
))
{
AnnotationUtils
.
getRepeatableAnnotations
(
method
,
Schedule
d
.
class
,
Schedules
.
class
))
{
processScheduled
(
scheduled
,
method
,
bean
);
annotatedMethods
.
add
(
method
);
}
...
...
spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java
浏览文件 @
27d1ce84
...
...
@@ -257,7 +257,7 @@ public abstract class AnnotationUtils {
@Deprecated
public
static
<
A
extends
Annotation
>
Set
<
A
>
getRepeatableAnnotation
(
Method
method
,
Class
<?
extends
Annotation
>
containerAnnotationType
,
Class
<
A
>
annotationType
)
{
return
getRepeatableAnnotations
(
method
,
containerAnnotationType
,
a
nnotationType
);
return
getRepeatableAnnotations
(
method
,
annotationType
,
containerA
nnotationType
);
}
/**
...
...
@@ -269,7 +269,7 @@ public abstract class AnnotationUtils {
@Deprecated
public
static
<
A
extends
Annotation
>
Set
<
A
>
getRepeatableAnnotation
(
AnnotatedElement
annotatedElement
,
Class
<?
extends
Annotation
>
containerAnnotationType
,
Class
<
A
>
annotationType
)
{
return
getRepeatableAnnotations
(
annotatedElement
,
containerAnnotationType
,
a
nnotationType
);
return
getRepeatableAnnotations
(
annotatedElement
,
annotationType
,
containerA
nnotationType
);
}
/**
...
...
@@ -287,9 +287,9 @@ public abstract class AnnotationUtils {
* <p>Meta-annotations will be searched if the annotation is not
* <em>present</em> on the supplied element.
* @param annotatedElement the element to look for annotations on; never {@code null}
* @param annotationType the annotation type to look for; never {@code null}
* @param containerAnnotationType the type of the container that holds
* the annotations; may be {@code null} if a container is not supported
* @param annotationType the annotation type to look for; never {@code null}
* @return the annotations found or an empty set; never {@code null}
* @since 4.2
* @see #getDeclaredRepeatableAnnotations(AnnotatedElement, Class, Class)
...
...
@@ -298,14 +298,14 @@ public abstract class AnnotationUtils {
* @see java.lang.reflect.AnnotatedElement#getAnnotationsByType
*/
public
static
<
A
extends
Annotation
>
Set
<
A
>
getRepeatableAnnotations
(
AnnotatedElement
annotatedElement
,
Class
<
?
extends
Annotation
>
containerAnnotationType
,
Class
<
A
>
a
nnotationType
)
{
Class
<
A
>
annotationType
,
Class
<?
extends
Annotation
>
containerA
nnotationType
)
{
Set
<
A
>
annotations
=
getDeclaredRepeatableAnnotations
(
annotatedElement
,
containerAnnotationType
,
a
nnotationType
);
Set
<
A
>
annotations
=
getDeclaredRepeatableAnnotations
(
annotatedElement
,
annotationType
,
containerA
nnotationType
);
if
(!
annotations
.
isEmpty
())
{
return
annotations
;
}
return
getRepeatableAnnotations
(
annotatedElement
,
containerAnnotationType
,
a
nnotationType
,
false
);
return
getRepeatableAnnotations
(
annotatedElement
,
annotationType
,
containerA
nnotationType
,
false
);
}
/**
...
...
@@ -323,9 +323,9 @@ public abstract class AnnotationUtils {
* <p>Meta-annotations will be searched if the annotation is not
* <em>present</em> on the supplied element.
* @param annotatedElement the element to look for annotations on; never {@code null}
* @param annotationType the annotation type to look for; never {@code null}
* @param containerAnnotationType the type of the container that holds
* the annotations; may be {@code null} if a container is not supported
* @param annotationType the annotation type to look for; never {@code null}
* @return the annotations found or an empty set; never {@code null}
* @since 4.2
* @see #getRepeatableAnnotations(AnnotatedElement, Class, Class)
...
...
@@ -334,8 +334,8 @@ public abstract class AnnotationUtils {
* @see java.lang.reflect.AnnotatedElement#getDeclaredAnnotationsByType
*/
public
static
<
A
extends
Annotation
>
Set
<
A
>
getDeclaredRepeatableAnnotations
(
AnnotatedElement
annotatedElement
,
Class
<
?
extends
Annotation
>
containerAnnotationType
,
Class
<
A
>
a
nnotationType
)
{
return
getRepeatableAnnotations
(
annotatedElement
,
containerAnnotationType
,
a
nnotationType
,
true
);
Class
<
A
>
annotationType
,
Class
<?
extends
Annotation
>
containerA
nnotationType
)
{
return
getRepeatableAnnotations
(
annotatedElement
,
annotationType
,
containerA
nnotationType
,
true
);
}
/**
...
...
@@ -347,9 +347,9 @@ public abstract class AnnotationUtils {
* <em>present</em> on the supplied element.
*
* @param annotatedElement the element to look for annotations on; never {@code null}
* @param annotationType the annotation type to look for; never {@code null}
* @param containerAnnotationType the type of the container that holds
* the annotations; may be {@code null} if a container is not supported
* @param annotationType the annotation type to look for; never {@code null}
* @param declaredMode {@code true} if only declared annotations (i.e.,
* directly or indirectly present) should be considered.
* @return the annotations found or an empty set; never {@code null}
...
...
@@ -358,7 +358,7 @@ public abstract class AnnotationUtils {
* @see java.lang.annotation.Repeatable
*/
private
static
<
A
extends
Annotation
>
Set
<
A
>
getRepeatableAnnotations
(
AnnotatedElement
annotatedElement
,
Class
<
?
extends
Annotation
>
containerAnnotationType
,
Class
<
A
>
a
nnotationType
,
boolean
declaredMode
)
{
Class
<
A
>
annotationType
,
Class
<?
extends
Annotation
>
containerA
nnotationType
,
boolean
declaredMode
)
{
Assert
.
notNull
(
annotatedElement
,
"annotatedElement must not be null"
);
Assert
.
notNull
(
annotationType
,
"annotationType must not be null"
);
...
...
@@ -367,7 +367,7 @@ public abstract class AnnotationUtils {
if
(
annotatedElement
instanceof
Method
)
{
annotatedElement
=
BridgeMethodResolver
.
findBridgedMethod
((
Method
)
annotatedElement
);
}
return
new
AnnotationCollector
<
A
>(
containerAnnotationType
,
a
nnotationType
,
declaredMode
).
getResult
(
annotatedElement
);
return
new
AnnotationCollector
<
A
>(
annotationType
,
containerA
nnotationType
,
declaredMode
).
getResult
(
annotatedElement
);
}
catch
(
Exception
ex
)
{
handleIntrospectionFailure
(
annotatedElement
,
ex
);
...
...
@@ -1665,10 +1665,10 @@ public abstract class AnnotationUtils {
private
static
class
AnnotationCollector
<
A
extends
Annotation
>
{
private
final
Class
<?
extends
Annotation
>
containerAnnotationType
;
private
final
Class
<
A
>
annotationType
;
private
final
Class
<?
extends
Annotation
>
containerAnnotationType
;
private
final
boolean
declaredMode
;
private
final
Set
<
AnnotatedElement
>
visited
=
new
HashSet
<
AnnotatedElement
>();
...
...
@@ -1676,9 +1676,9 @@ public abstract class AnnotationUtils {
private
final
Set
<
A
>
result
=
new
LinkedHashSet
<
A
>();
AnnotationCollector
(
Class
<?
extends
Annotation
>
containerAnnotationType
,
Class
<
A
>
annotationType
,
boolean
declaredMode
)
{
this
.
containerAnnotationType
=
containerAnnotationType
;
AnnotationCollector
(
Class
<
A
>
annotationType
,
Class
<?
extends
Annotation
>
containerAnnotationType
,
boolean
declaredMode
)
{
this
.
annotationType
=
annotationType
;
this
.
containerAnnotationType
=
containerAnnotationType
;
this
.
declaredMode
=
declaredMode
;
}
...
...
@@ -1691,7 +1691,7 @@ public abstract class AnnotationUtils {
private
void
process
(
AnnotatedElement
element
)
{
if
(
this
.
visited
.
add
(
element
))
{
try
{
Annotation
[]
annotations
=
(
declaredMode
?
element
.
getDeclaredAnnotations
()
:
element
.
getAnnotations
());
Annotation
[]
annotations
=
(
this
.
declaredMode
?
element
.
getDeclaredAnnotations
()
:
element
.
getAnnotations
());
for
(
Annotation
ann
:
annotations
)
{
Class
<?
extends
Annotation
>
currentAnnotationType
=
ann
.
annotationType
();
if
(
ObjectUtils
.
nullSafeEquals
(
this
.
annotationType
,
currentAnnotationType
))
{
...
...
spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java
浏览文件 @
27d1ce84
...
...
@@ -501,7 +501,7 @@ public class AnnotationUtilsTests {
@Test
public
void
getRepeatableAnnotationsDeclaredOnMethod
()
throws
Exception
{
Method
method
=
InterfaceWithRepeated
.
class
.
getMethod
(
"foo"
);
Set
<
MyRepeatable
>
annotations
=
getRepeatableAnnotations
(
method
,
MyRepeatable
Container
.
class
,
MyRepeatable
.
class
);
Set
<
MyRepeatable
>
annotations
=
getRepeatableAnnotations
(
method
,
MyRepeatable
.
class
,
MyRepeatableContainer
.
class
);
assertNotNull
(
annotations
);
List
<
String
>
values
=
annotations
.
stream
().
map
(
MyRepeatable:
:
value
).
collect
(
toList
());
assertThat
(
values
,
is
(
Arrays
.
asList
(
"A"
,
"B"
,
"C"
,
"meta1"
)));
...
...
@@ -513,14 +513,14 @@ public class AnnotationUtilsTests {
exception
.
expectMessage
(
containsString
(
"Attribute [value] in"
));
exception
.
expectMessage
(
containsString
(
BrokenContextConfig
.
class
.
getName
()));
exception
.
expectMessage
(
containsString
(
"must be declared as an @AliasFor [locations]"
));
getRepeatableAnnotations
(
BrokenConfigHierarchyTestCase
.
class
,
Broken
Hierarchy
.
class
,
BrokenContextConfig
.
class
);
getRepeatableAnnotations
(
BrokenConfigHierarchyTestCase
.
class
,
Broken
ContextConfig
.
class
,
BrokenHierarchy
.
class
);
}
@Test
public
void
getRepeatableAnnotationsDeclaredOnClassWithAttributeAliases
()
throws
Exception
{
final
List
<
String
>
expectedLocations
=
Arrays
.
asList
(
"A"
,
"B"
);
Set
<
ContextConfig
>
annotations
=
getRepeatableAnnotations
(
ConfigHierarchyTestCase
.
class
,
Hierarchy
.
class
,
ContextConfig
.
class
);
Set
<
ContextConfig
>
annotations
=
getRepeatableAnnotations
(
ConfigHierarchyTestCase
.
class
,
ContextConfig
.
class
,
Hierarchy
.
class
);
assertNotNull
(
annotations
);
List
<
String
>
locations
=
annotations
.
stream
().
map
(
ContextConfig:
:
locations
).
collect
(
toList
());
...
...
@@ -542,7 +542,7 @@ public class AnnotationUtilsTests {
assertThat
(
values
,
is
(
expectedValuesJava
));
// Spring
Set
<
MyRepeatable
>
set
=
getRepeatableAnnotations
(
MyRepeatableClass
.
class
,
MyRepeatable
Container
.
class
,
MyRepeatable
.
class
);
Set
<
MyRepeatable
>
set
=
getRepeatableAnnotations
(
MyRepeatableClass
.
class
,
MyRepeatable
.
class
,
MyRepeatableContainer
.
class
);
assertNotNull
(
set
);
values
=
set
.
stream
().
map
(
MyRepeatable:
:
value
).
collect
(
toList
());
assertThat
(
values
,
is
(
expectedValuesSpring
));
...
...
@@ -561,7 +561,7 @@ public class AnnotationUtilsTests {
assertThat
(
values
,
is
(
expectedValuesJava
));
// Spring
Set
<
MyRepeatable
>
set
=
getRepeatableAnnotations
(
clazz
,
MyRepeatable
Container
.
class
,
MyRepeatable
.
class
);
Set
<
MyRepeatable
>
set
=
getRepeatableAnnotations
(
clazz
,
MyRepeatable
.
class
,
MyRepeatableContainer
.
class
);
assertNotNull
(
set
);
values
=
set
.
stream
().
map
(
MyRepeatable:
:
value
).
collect
(
toList
());
assertThat
(
values
,
is
(
expectedValuesSpring
));
...
...
@@ -580,7 +580,7 @@ public class AnnotationUtilsTests {
assertThat
(
values
,
is
(
expectedValuesJava
));
// Spring
Set
<
MyRepeatable
>
set
=
getRepeatableAnnotations
(
clazz
,
MyRepeatable
Container
.
class
,
MyRepeatable
.
class
);
Set
<
MyRepeatable
>
set
=
getRepeatableAnnotations
(
clazz
,
MyRepeatable
.
class
,
MyRepeatableContainer
.
class
);
assertNotNull
(
set
);
values
=
set
.
stream
().
map
(
MyRepeatable:
:
value
).
collect
(
toList
());
assertThat
(
values
,
is
(
expectedValuesSpring
));
...
...
@@ -598,7 +598,7 @@ public class AnnotationUtilsTests {
assertThat
(
values
,
is
(
expectedValuesJava
));
// Spring
Set
<
MyRepeatable
>
set
=
getDeclaredRepeatableAnnotations
(
MyRepeatableClass
.
class
,
MyRepeatable
Container
.
class
,
MyRepeatable
.
class
);
Set
<
MyRepeatable
>
set
=
getDeclaredRepeatableAnnotations
(
MyRepeatableClass
.
class
,
MyRepeatable
.
class
,
MyRepeatableContainer
.
class
);
assertNotNull
(
set
);
values
=
set
.
stream
().
map
(
MyRepeatable:
:
value
).
collect
(
toList
());
assertThat
(
values
,
is
(
expectedValuesSpring
));
...
...
@@ -614,7 +614,7 @@ public class AnnotationUtilsTests {
assertThat
(
array
.
length
,
is
(
0
));
// Spring
Set
<
MyRepeatable
>
set
=
getDeclaredRepeatableAnnotations
(
clazz
,
MyRepeatable
Container
.
class
,
MyRepeatable
.
class
);
Set
<
MyRepeatable
>
set
=
getDeclaredRepeatableAnnotations
(
clazz
,
MyRepeatable
.
class
,
MyRepeatableContainer
.
class
);
assertNotNull
(
set
);
assertThat
(
set
.
size
(),
is
(
0
));
}
...
...
spring-test/src/main/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListener.java
浏览文件 @
27d1ce84
...
...
@@ -123,11 +123,11 @@ public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListen
private
void
executeSqlScripts
(
TestContext
testContext
,
ExecutionPhase
executionPhase
)
throws
Exception
{
boolean
classLevel
=
false
;
Set
<
Sql
>
sqlAnnotations
=
AnnotationUtils
.
getRepeatableAnnotations
(
testContext
.
getTestMethod
(),
Sql
Group
.
class
,
Sql
.
class
);
Set
<
Sql
>
sqlAnnotations
=
AnnotationUtils
.
getRepeatableAnnotations
(
testContext
.
getTestMethod
(),
Sql
.
class
,
Sql
Group
.
class
);
if
(
sqlAnnotations
.
isEmpty
())
{
sqlAnnotations
=
AnnotationUtils
.
getRepeatableAnnotations
(
testContext
.
getTestClass
(),
Sql
Group
.
class
,
Sql
.
class
);
sqlAnnotations
=
AnnotationUtils
.
getRepeatableAnnotations
(
testContext
.
getTestClass
(),
Sql
.
class
,
Sql
Group
.
class
);
if
(!
sqlAnnotations
.
isEmpty
())
{
classLevel
=
true
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录