Ensure there is a single bootstrap parent context

Only one neds to be created, and once it is in place in the hierarchy
it should be usable by all the child contexts that get added.

Fixes gh-153
This commit is contained in:
Dave Syer
2017-02-24 09:33:51 +00:00
parent 8347c5741c
commit 331e790026
4 changed files with 123 additions and 0 deletions

View File

@@ -81,6 +81,11 @@ public class BootstrapApplicationListener
if (environment.getPropertySources().contains(BOOTSTRAP_PROPERTY_SOURCE_NAME)) {
return;
}
for (ApplicationContextInitializer<?> initializer : event.getSpringApplication().getInitializers()) {
if (initializer instanceof ParentContextApplicationContextInitializer) {
return;
}
}
ConfigurableApplicationContext context = bootstrapServiceContext(environment,
event.getSpringApplication());
apply(context, event.getSpringApplication(), environment);