Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
8f90eacd
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,发现更多精彩内容 >>
提交
8f90eacd
编写于
8月 26, 2013
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
aecf60d2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
26 deletion
+18
-26
spring-context/src/main/java/org/springframework/context/annotation/ConditionEvaluator.java
...pringframework/context/annotation/ConditionEvaluator.java
+13
-21
spring-context/src/main/java/org/springframework/context/annotation/Profile.java
.../java/org/springframework/context/annotation/Profile.java
+3
-3
spring-core/src/main/java/org/springframework/util/ClassUtils.java
...re/src/main/java/org/springframework/util/ClassUtils.java
+2
-2
未找到文件。
spring-context/src/main/java/org/springframework/context/annotation/ConditionEvaluator.java
浏览文件 @
8f90eacd
...
...
@@ -42,9 +42,6 @@ import org.springframework.util.MultiValueMap;
*/
class
ConditionEvaluator
{
private
static
final
String
CONDITIONAL_ANNOTATION
=
Conditional
.
class
.
getName
();
private
final
ConditionContextImpl
context
;
...
...
@@ -52,10 +49,9 @@ class ConditionEvaluator {
* Create a new {@link ConditionEvaluator} instance.
*/
public
ConditionEvaluator
(
BeanDefinitionRegistry
registry
,
Environment
environment
,
ApplicationContext
applicationContext
,
ClassLoader
classLoader
,
ResourceLoader
resourceLoader
)
{
this
.
context
=
new
ConditionContextImpl
(
registry
,
environment
,
applicationContext
,
classLoader
,
resourceLoader
);
ApplicationContext
applicationContext
,
ClassLoader
classLoader
,
ResourceLoader
resourceLoader
)
{
this
.
context
=
new
ConditionContextImpl
(
registry
,
environment
,
applicationContext
,
classLoader
,
resourceLoader
);
}
...
...
@@ -77,7 +73,7 @@ class ConditionEvaluator {
* @return if the item should be skipped
*/
public
boolean
shouldSkip
(
AnnotatedTypeMetadata
metadata
,
ConfigurationPhase
phase
)
{
if
(
metadata
==
null
||
!
metadata
.
isAnnotated
(
C
ONDITIONAL_ANNOTATION
))
{
if
(
metadata
==
null
||
!
metadata
.
isAnnotated
(
C
onditional
.
class
.
getName
()
))
{
return
false
;
}
...
...
@@ -108,16 +104,13 @@ class ConditionEvaluator {
@SuppressWarnings
(
"unchecked"
)
private
List
<
String
[]>
getConditionClasses
(
AnnotatedTypeMetadata
metadata
)
{
MultiValueMap
<
String
,
Object
>
attributes
=
metadata
.
getAllAnnotationAttributes
(
CONDITIONAL_ANNOTATION
,
true
);
Object
values
=
attributes
==
null
?
null
:
attributes
.
get
(
"value"
);
return
(
List
<
String
[]>)
(
values
==
null
?
Collections
.
emptyList
()
:
values
);
MultiValueMap
<
String
,
Object
>
attributes
=
metadata
.
getAllAnnotationAttributes
(
Conditional
.
class
.
getName
(),
true
);
Object
values
=
(
attributes
!=
null
?
attributes
.
get
(
"value"
)
:
null
);
return
(
List
<
String
[]>)
(
values
!=
null
?
values
:
Collections
.
emptyList
());
}
private
Condition
getCondition
(
String
conditionClassName
,
ClassLoader
classloader
)
{
Class
<?>
conditionClass
=
ClassUtils
.
resolveClassName
(
conditionClassName
,
classloader
);
private
Condition
getCondition
(
String
conditionClassName
,
ClassLoader
classloader
)
{
Class
<?>
conditionClass
=
ClassUtils
.
resolveClassName
(
conditionClassName
,
classloader
);
return
(
Condition
)
BeanUtils
.
instantiateClass
(
conditionClass
);
}
...
...
@@ -139,7 +132,6 @@ class ConditionEvaluator {
private
ResourceLoader
resourceLoader
;
public
ConditionContextImpl
(
BeanDefinitionRegistry
registry
,
Environment
environment
,
ApplicationContext
applicationContext
,
ClassLoader
classLoader
,
ResourceLoader
resourceLoader
)
{
...
...
@@ -169,7 +161,7 @@ class ConditionEvaluator {
if
(
this
.
registry
!=
null
)
{
return
this
.
registry
;
}
if
(
getBeanFactory
()
!=
null
&&
getBeanFactory
()
instanceof
BeanDefinitionRegistry
)
{
if
(
getBeanFactory
()
instanceof
BeanDefinitionRegistry
)
{
return
(
BeanDefinitionRegistry
)
getBeanFactory
();
}
return
null
;
...
...
@@ -180,7 +172,7 @@ class ConditionEvaluator {
if
(
this
.
environment
!=
null
)
{
return
this
.
environment
;
}
if
(
getRegistry
()
!=
null
&&
getRegistry
()
instanceof
EnvironmentCapable
)
{
if
(
getRegistry
()
instanceof
EnvironmentCapable
)
{
return
((
EnvironmentCapable
)
getRegistry
()).
getEnvironment
();
}
return
null
;
...
...
@@ -197,7 +189,7 @@ class ConditionEvaluator {
if
(
this
.
resourceLoader
!=
null
)
{
return
this
.
resourceLoader
;
}
if
(
registry
instanceof
ResourceLoader
)
{
if
(
this
.
registry
instanceof
ResourceLoader
)
{
return
(
ResourceLoader
)
registry
;
}
return
null
;
...
...
@@ -219,7 +211,7 @@ class ConditionEvaluator {
if
(
this
.
applicationContext
!=
null
)
{
return
this
.
applicationContext
;
}
if
(
getRegistry
()
!=
null
&&
getRegistry
()
instanceof
ApplicationContext
)
{
if
(
getRegistry
()
instanceof
ApplicationContext
)
{
return
(
ApplicationContext
)
getRegistry
();
}
return
null
;
...
...
spring-context/src/main/java/org/springframework/context/annotation/Profile.java
浏览文件 @
8f90eacd
...
...
@@ -45,11 +45,11 @@ import org.springframework.core.env.ConfigurableEnvironment;
*
* <p>If a {@code @Configuration} class is marked with {@code @Profile}, all of the
* {@code @Bean} methods and {@link Import @Import} annotations associated with that class
* will be bypassed unless one or more the specified profiles are active. This is very
* will be bypassed unless one or more
of
the specified profiles are active. This is very
* similar to the behavior in Spring XML: if the {@code profile} attribute of the
* {@code beans} element is supplied e.g., {@code <beans profile="p1,p2">}, the
* {@code beans} element will not be parsed unless profiles 'p1' and/or 'p2' have been
* activated.
Likewise, if a {@code @Component} or {@code @Configuration} class is marked
* activated. Likewise, if a {@code @Component} or {@code @Configuration} class is marked
* with {@code @Profile({"p1", "p2"})}, that class will not be registered/processed unless
* profiles 'p1' and/or 'p2' have been activated.
*
...
...
@@ -74,7 +74,7 @@ import org.springframework.core.env.ConfigurableEnvironment;
* @see AbstractEnvironment#DEFAULT_PROFILES_PROPERTY_NAME
*/
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
({
ElementType
.
TYPE
,
ElementType
.
METHOD
})
@Target
({
ElementType
.
TYPE
,
ElementType
.
METHOD
})
@Conditional
(
ProfileCondition
.
class
)
public
@interface
Profile
{
...
...
spring-core/src/main/java/org/springframework/util/ClassUtils.java
浏览文件 @
8f90eacd
/*
* 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.
...
...
@@ -746,7 +746,7 @@ public abstract class ClassUtils {
/**
* Return a public static method of a class.
* @param methodName the static method name
* @param clazz
the class which defines the method
* @param clazz the class which defines the method
* @param args the parameter types to the method
* @return the static method, or {@code null} if no static method was found
* @throws IllegalArgumentException if the method name is blank or the clazz is null
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录