Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wrr-cat
apollo
提交
75878e16
apollo
项目概览
wrr-cat
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
75878e16
编写于
3月 08, 2017
作者:
张
张乐
提交者:
GitHub
3月 08, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #560 from nobodyiam/apollo-spring-fix
minor fix for Spring
上级
6f30d521
9b06053c
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
21 addition
and
9 deletion
+21
-9
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloAnnotationProcessor.java
...k/apollo/spring/annotation/ApolloAnnotationProcessor.java
+8
-1
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java
...mework/apollo/spring/config/PropertySourcesProcessor.java
+13
-8
未找到文件。
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloAnnotationProcessor.java
浏览文件 @
75878e16
...
...
@@ -9,6 +9,8 @@ import com.ctrip.framework.apollo.model.ConfigChangeEvent;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.config.BeanPostProcessor
;
import
org.springframework.core.Ordered
;
import
org.springframework.core.PriorityOrdered
;
import
org.springframework.core.annotation.AnnotationUtils
;
import
org.springframework.util.ReflectionUtils
;
...
...
@@ -20,7 +22,7 @@ import java.lang.reflect.Method;
*
* @author Jason Song(song_s@ctrip.com)
*/
public
class
ApolloAnnotationProcessor
implements
BeanPostProcessor
{
public
class
ApolloAnnotationProcessor
implements
BeanPostProcessor
,
PriorityOrdered
{
@Override
public
Object
postProcessBeforeInitialization
(
Object
bean
,
String
beanName
)
throws
BeansException
{
Class
clazz
=
bean
.
getClass
();
...
...
@@ -80,4 +82,9 @@ public class ApolloAnnotationProcessor implements BeanPostProcessor {
}
}
@Override
public
int
getOrder
()
{
//make it as late as possible
return
Ordered
.
LOWEST_PRECEDENCE
;
}
}
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java
浏览文件 @
75878e16
...
...
@@ -11,6 +11,8 @@ import org.springframework.beans.BeansException;
import
org.springframework.beans.factory.config.BeanFactoryPostProcessor
;
import
org.springframework.beans.factory.config.ConfigurableListableBeanFactory
;
import
org.springframework.context.EnvironmentAware
;
import
org.springframework.core.Ordered
;
import
org.springframework.core.PriorityOrdered
;
import
org.springframework.core.env.CompositePropertySource
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.Environment
;
...
...
@@ -24,10 +26,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
*
* @author Jason Song(song_s@ctrip.com)
*/
public
class
PropertySourcesProcessor
implements
BeanFactoryPostProcessor
,
EnvironmentAware
{
public
class
PropertySourcesProcessor
implements
BeanFactoryPostProcessor
,
EnvironmentAware
,
PriorityOrdered
{
private
static
final
String
APOLLO_PROPERTY_SOURCE_NAME
=
"ApolloPropertySources"
;
private
static
final
Multimap
<
Integer
,
String
>
NAMESPACE_NAMES
=
HashMultimap
.
create
();
private
static
final
AtomicBoolean
PROPERTY_SOURCES_INITIALIZED
=
new
AtomicBoolean
(
false
);
private
ConfigurableEnvironment
environment
;
...
...
@@ -37,15 +38,14 @@ public class PropertySourcesProcessor implements BeanFactoryPostProcessor, Envir
@Override
public
void
postProcessBeanFactory
(
ConfigurableListableBeanFactory
beanFactory
)
throws
BeansException
{
if
(!
PROPERTY_SOURCES_INITIALIZED
.
compareAndSet
(
false
,
true
))
{
//already initialized
return
;
}
initializePropertySources
();
}
protected
void
initializePropertySources
()
{
if
(
environment
.
getPropertySources
().
contains
(
APOLLO_PROPERTY_SOURCE_NAME
))
{
//already initialized
return
;
}
CompositePropertySource
composite
=
new
CompositePropertySource
(
APOLLO_PROPERTY_SOURCE_NAME
);
//sort by order asc
...
...
@@ -72,6 +72,11 @@ public class PropertySourcesProcessor implements BeanFactoryPostProcessor, Envir
//only for test
private
static
void
reset
()
{
NAMESPACE_NAMES
.
clear
();
PROPERTY_SOURCES_INITIALIZED
.
set
(
false
);
}
@Override
public
int
getOrder
()
{
//make it as early as possible
return
Ordered
.
HIGHEST_PRECEDENCE
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录