From 247ee100eeba57f208774fe889988387ca585ed0 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Thu, 30 Oct 2014 11:47:43 +0000 Subject: [PATCH] Sync docs from master to gh-pages --- spring-cloud.html | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/spring-cloud.html b/spring-cloud.html index 12de7ed..bf5aec2 100644 --- a/spring-cloud.html +++ b/spring-cloud.html @@ -1196,12 +1196,15 @@ interface, or with the SpringApplicationBuilder convenience methods (parent(), child() and sibling()). Note that the SpringApplicationBuilder allows you to share an Environment amongst the whole hierarchy, but that is not the default. Thus, -normally you expect to see differences between different levels in the -hierarchy, and sibling contexts in particular do not need to have the -same profiles or property sources, even though they will share common -things with their parent. Every context in the hierarchy will have its -own "bootstrap" property source (possibly empty) to avoid promoting -values inadvertently from parents down to their descendants.

+sibling contexts in particular do not need to have the same profiles +or property sources, even though they will share common things with +their parent. Every context in the hierarchy will have its own +"bootstrap" property source (possibly empty) to avoid promoting values +inadvertently from parents down to their descendants. Every context in +the hierarchy can also (in principle) have a different +spring.application.name and hence a different remote property source +if there is a Config Server. Remember that properties from a child +context override those in the parent.

@@ -1261,14 +1264,24 @@ database, for instance.

public class CustomPropertySourceLocator implements PropertySourceLocator { @Override - public PropertySource<?> locate() { + public PropertySource<?> locate(Environment environment) { return new MapPropertySource("customProperty", Collections.<String, Object>singletonMap("property.from.sample.custom.source", "worked as intended")); } + }
+

The Environment that is passed in is the one for the +ApplicationContext about to be created, i.e. the one that we are +supplying additional property sources for. It will already have its +normal Spring Boot-provided property sources, so you can use those to +locate a property source specific to this Environment (e.g. by +keying it on the spring.application.name, as is done in the default +Config Server property source locator).

+
+

If you create a jar with this class in it and then add a META-INF/spring.factories containing:

@@ -2183,7 +2196,7 @@ and puts it in a request header for the downstream requests.