Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
apollo
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
apollo
Commits
5740bcdb
Commit
5740bcdb
authored
Sep 02, 2018
by
nobodyiam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix #1034, to make sure ApolloBootstrapPropertySources is in the first place
parent
737e86f3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java
...mework/apollo/spring/config/PropertySourcesProcessor.java
+21
-0
No files found.
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java
View file @
5740bcdb
...
...
@@ -25,6 +25,8 @@ import org.springframework.core.env.Environment;
import
java.util.Collection
;
import
java.util.Iterator
;
import
org.springframework.core.env.MutablePropertySources
;
import
org.springframework.core.env.PropertySource
;
/**
* Apollo Property Sources processor for Spring Annotation Based Application. <br /> <br />
...
...
@@ -81,6 +83,10 @@ public class PropertySourcesProcessor implements BeanFactoryPostProcessor, Envir
// add after the bootstrap property source or to the first
if
(
environment
.
getPropertySources
()
.
contains
(
PropertySourcesConstants
.
APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME
))
{
// ensure ApolloBootstrapPropertySources is still the first
ensureBootstrapPropertyPrecedence
(
environment
);
environment
.
getPropertySources
()
.
addAfter
(
PropertySourcesConstants
.
APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME
,
composite
);
}
else
{
...
...
@@ -88,6 +94,21 @@ public class PropertySourcesProcessor implements BeanFactoryPostProcessor, Envir
}
}
private
void
ensureBootstrapPropertyPrecedence
(
ConfigurableEnvironment
environment
)
{
MutablePropertySources
propertySources
=
environment
.
getPropertySources
();
PropertySource
<?>
bootstrapPropertySource
=
propertySources
.
get
(
PropertySourcesConstants
.
APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME
);
// not exists or already in the first place
if
(
bootstrapPropertySource
==
null
||
propertySources
.
precedenceOf
(
bootstrapPropertySource
)
==
0
)
{
return
;
}
propertySources
.
remove
(
PropertySourcesConstants
.
APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME
);
propertySources
.
addFirst
(
bootstrapPropertySource
);
}
private
void
initializeAutoUpdatePropertiesFeature
(
ConfigurableListableBeanFactory
beanFactory
)
{
if
(!
configUtil
.
isAutoUpdateInjectedSpringPropertiesEnabled
())
{
return
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment