Add BootstrapRegistry for long lived instances

Add a simple `BootstrapRegistry` that can be used to store and share
object instances across `EnvironmentPostProcessors`. The registry
can be injected into the constructor of any `EnvironmentPostProcessor`.

Registrations can also perform additional actions when the
`ApplicationContext` has been prepared. For example, they could register
the the bootstrap instances as beans so that they become available to
the application.

See gh-22956
This commit is contained in:
Phillip Webb
2020-08-20 12:51:34 -07:00
parent 167e31d564
commit 2260657781
11 changed files with 542 additions and 85 deletions

View File

@@ -74,7 +74,7 @@ public final class RemoteSpringApplication {
List<ApplicationListener<?>> listeners = new ArrayList<>();
listeners.add(new AnsiOutputApplicationListener());
listeners.add(new EnvironmentPostProcessorApplicationListener(
EnvironmentPostProcessorsFactory.singleton(ConfigDataEnvironmentPostProcessor::new)));
EnvironmentPostProcessorsFactory.of(ConfigDataEnvironmentPostProcessor.class)));
listeners.add(new ClasspathLoggingApplicationListener());
listeners.add(new LoggingApplicationListener());
listeners.add(new RemoteUrlPropertyExtractor());