Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.-Smile-.
spring-framework
提交
c88877f1
S
spring-framework
项目概览
.-Smile-.
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
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,发现更多精彩内容 >>
提交
c88877f1
编写于
11月 05, 2015
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
9683da52
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
17 addition
and
17 deletion
+17
-17
spring-core/src/main/java/org/springframework/core/annotation/AbstractAliasAwareAnnotationAttributeExtractor.java
...ation/AbstractAliasAwareAnnotationAttributeExtractor.java
+4
-4
spring-core/src/main/java/org/springframework/core/annotation/MapAnnotationAttributeExtractor.java
...work/core/annotation/MapAnnotationAttributeExtractor.java
+12
-12
spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java
...rg/springframework/core/type/AnnotationMetadataTests.java
+1
-1
未找到文件。
spring-core/src/main/java/org/springframework/core/annotation/AbstractAliasAwareAnnotationAttributeExtractor.java
浏览文件 @
c88877f1
...
...
@@ -55,8 +55,8 @@ abstract class AbstractAliasAwareAnnotationAttributeExtractor<S> implements Anno
* of the supplied type; may be {@code null} if unknown
* @param source the underlying source of annotation attributes; never {@code null}
*/
AbstractAliasAwareAnnotationAttributeExtractor
(
Class
<?
extends
Annotation
>
annotationType
,
AnnotatedElement
annotatedElement
,
S
source
)
{
AbstractAliasAwareAnnotationAttributeExtractor
(
Class
<?
extends
Annotation
>
annotationType
,
AnnotatedElement
annotatedElement
,
S
source
)
{
Assert
.
notNull
(
annotationType
,
"annotationType must not be null"
);
Assert
.
notNull
(
source
,
"source must not be null"
);
...
...
@@ -84,12 +84,12 @@ abstract class AbstractAliasAwareAnnotationAttributeExtractor<S> implements Anno
@Override
public
final
Object
getAttributeValue
(
Method
attributeMethod
)
{
final
String
attributeName
=
attributeMethod
.
getName
();
String
attributeName
=
attributeMethod
.
getName
();
Object
attributeValue
=
getRawAttributeValue
(
attributeMethod
);
List
<
String
>
aliasNames
=
this
.
attributeAliasMap
.
get
(
attributeName
);
if
(
aliasNames
!=
null
)
{
final
Object
defaultValue
=
AnnotationUtils
.
getDefaultValue
(
getAnnotationType
(),
attributeName
);
Object
defaultValue
=
AnnotationUtils
.
getDefaultValue
(
getAnnotationType
(),
attributeName
);
for
(
String
aliasName
:
aliasNames
)
{
Object
aliasValue
=
getRawAttributeValue
(
aliasName
);
...
...
spring-core/src/main/java/org/springframework/core/annotation/MapAnnotationAttributeExtractor.java
浏览文件 @
c88877f1
...
...
@@ -121,33 +121,33 @@ class MapAnnotationAttributeExtractor extends AbstractAliasAwareAnnotationAttrib
// if still null
if
(
attributeValue
==
null
)
{
throw
new
IllegalArgumentException
(
String
.
format
(
"Attributes map [%s] returned null for required attribute [%s] defined by annotation type [%s]."
,
attributes
,
attributeName
,
annotationType
.
getName
()));
"Attributes map [%s] returned null for required attribute [%s] defined by annotation type [%s]."
,
attributes
,
attributeName
,
annotationType
.
getName
()));
}
// finally, ensure correct type
Class
<?>
requiredReturnType
=
attributeMethod
.
getReturnType
();
Class
<?
extends
Object
>
actualReturnType
=
attributeValue
.
getClass
();
if
(!
ClassUtils
.
isAssignable
(
requiredReturnType
,
actualReturnType
))
{
boolean
converted
=
false
;
// Nested map representing a single annotation?
if
(
Annotation
.
class
.
isAssignableFrom
(
requiredReturnType
)
&&
Map
.
class
.
isAssignableFrom
(
actualReturnType
))
{
Class
<?
extends
Annotation
>
nestedAnnotationType
=
(
Class
<?
extends
Annotation
>)
requiredReturnType
;
if
(
Annotation
.
class
.
isAssignableFrom
(
requiredReturnType
)
&&
Map
.
class
.
isAssignableFrom
(
actualReturnType
))
{
Class
<?
extends
Annotation
>
nestedAnnotationType
=
(
Class
<?
extends
Annotation
>)
requiredReturnType
;
Map
<
String
,
Object
>
map
=
(
Map
<
String
,
Object
>)
attributeValue
;
attributes
.
put
(
attributeName
,
synthesizeAnnotation
(
map
,
nestedAnnotationType
,
null
));
converted
=
true
;
}
// Nested array of maps representing an array of annotations?
else
if
(
requiredReturnType
.
isArray
()
&&
Annotation
.
class
.
isAssignableFrom
(
requiredReturnType
.
getComponentType
())
&&
actualReturnType
.
isArray
()
&&
Map
.
class
.
isAssignableFrom
(
actualReturnType
.
getComponentType
()))
{
Class
<?
extends
Annotation
>
nestedAnnotationType
=
(
Class
<?
extends
Annotation
>)
requiredReturnType
.
getComponentType
();
else
if
(
requiredReturnType
.
isArray
()
&&
actualReturnType
.
isArray
()
&&
Annotation
.
class
.
isAssignableFrom
(
requiredReturnType
.
getComponentType
())
&&
Map
.
class
.
isAssignableFrom
(
actualReturnType
.
getComponentType
()))
{
Class
<?
extends
Annotation
>
nestedAnnotationType
=
(
Class
<?
extends
Annotation
>)
requiredReturnType
.
getComponentType
();
Map
<
String
,
Object
>[]
maps
=
(
Map
<
String
,
Object
>[])
attributeValue
;
attributes
.
put
(
attributeName
,
synthesizeAnnotationArray
(
maps
,
nestedAnnotationType
));
converted
=
true
;
...
...
spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java
浏览文件 @
c88877f1
...
...
@@ -194,7 +194,7 @@ public class AnnotationMetadataTests {
private
void
assertMetaAnnotationOverrides
(
AnnotationMetadata
metadata
)
{
AnnotationAttributes
attributes
=
(
AnnotationAttributes
)
metadata
.
getAnnotationAttributes
(
TestComponentScan
.
class
.
getName
(),
false
);
TestComponentScan
.
class
.
getName
(),
false
);
String
[]
basePackages
=
attributes
.
getStringArray
(
"basePackages"
);
assertThat
(
"length of basePackages[]"
,
basePackages
.
length
,
is
(
1
));
assertThat
(
"basePackages[0]"
,
basePackages
[
0
],
is
(
"org.example.componentscan"
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录