Refactor BootstrapRegistry support
Refactor `BootstrapRegistry` support following initial prototype work with the Spring Cloud team. This update splits the `BootstrapRegistry` API into `BootstrapRegistry`, `BootstrapContext` and `ConfigurableBootstrapContext` interfaces and moves it to the same package as `SpringApplication`. A new `Bootstrapper` interface has been introduced that can be added to the `SpringApplication` to customize the `BootstrapRegistry` before it's used. Closes gh-23326
This commit is contained in:
@@ -16,10 +16,10 @@
|
||||
|
||||
package org.springframework.boot.test.context;
|
||||
|
||||
import org.springframework.boot.DefaultBootstrapContext;
|
||||
import org.springframework.boot.DefaultPropertiesPropertySource;
|
||||
import org.springframework.boot.context.config.ConfigData;
|
||||
import org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor;
|
||||
import org.springframework.boot.env.DefaultBootstrapRegisty;
|
||||
import org.springframework.boot.env.RandomValuePropertySource;
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
@@ -42,9 +42,9 @@ public class ConfigDataApplicationContextInitializer
|
||||
public void initialize(ConfigurableApplicationContext applicationContext) {
|
||||
ConfigurableEnvironment environment = applicationContext.getEnvironment();
|
||||
RandomValuePropertySource.addToEnvironment(environment);
|
||||
DefaultBootstrapRegisty bootstrapRegistry = new DefaultBootstrapRegisty();
|
||||
ConfigDataEnvironmentPostProcessor.applyTo(environment, applicationContext, bootstrapRegistry);
|
||||
bootstrapRegistry.applicationContextPrepared(applicationContext);
|
||||
DefaultBootstrapContext bootstrapContext = new DefaultBootstrapContext();
|
||||
ConfigDataEnvironmentPostProcessor.applyTo(environment, applicationContext, bootstrapContext);
|
||||
bootstrapContext.close(applicationContext);
|
||||
DefaultPropertiesPropertySource.moveToEnd(environment);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user