Ensure /refresh reloads bootstrap configurations

Some changes a while back had switched off refreshing the bootstrap config
(because of the way it was being detected in an existing environment to prevent
an infinite loop). This change fixes that by adding a dummy property source
during bootstrap and then removing it again.
This commit is contained in:
Dave Syer
2014-07-17 08:26:10 +01:00
parent de3acf6da0
commit 67c0aa9dbf

View File

@@ -66,7 +66,7 @@ public class BootstrapApplicationListener implements
if (environment instanceof ConfigurableEnvironment) {
ConfigurableEnvironment configurable = (ConfigurableEnvironment) environment;
// don't listen to events in a bootstrap context
if (configurable.getPropertySources().contains("bootstrap")) {
if (configurable.getPropertySources().contains("bootstrapInProgress")) {
return;
}
ConfigurableApplicationContext context = bootstrapServiceContext(
@@ -82,6 +82,7 @@ public class BootstrapApplicationListener implements
for (PropertySource<?> source : bootstrapProperties) {
bootstrapProperties.remove(source.getName());
}
bootstrapProperties.addFirst(new MapPropertySource("bootstrapInProgress", Collections.<String,Object>emptyMap()));
for (PropertySource<?> source : environment.getPropertySources()) {
bootstrapProperties.addLast(source);
}
@@ -100,6 +101,7 @@ public class BootstrapApplicationListener implements
final ConfigurableApplicationContext context = builder.run();
// Make the bootstrap context a parent of the app context
addAncestorInitializer(application, context);
bootstrapProperties.remove("bootstrapInProgress");
return context;
}