Add BootstrapRegisty support for config data
Expose the `BootstrapRegisty` to both `ConfigDataLocationResolver` and `ConfigDataLoader` implementations. The registry is exposed via the context interfaces and may be used to reuse instances that are expensive to create. It may also be used to ultimately register beans with the `ApplicationContext`. Closes gh-22956
This commit is contained in:
@@ -18,6 +18,7 @@ package org.springframework.boot.test.context;
|
||||
|
||||
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.DefaultPropertiesPropertySource;
|
||||
import org.springframework.boot.env.RandomValuePropertySource;
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
@@ -41,7 +42,9 @@ public class ConfigDataApplicationContextInitializer
|
||||
public void initialize(ConfigurableApplicationContext applicationContext) {
|
||||
ConfigurableEnvironment environment = applicationContext.getEnvironment();
|
||||
RandomValuePropertySource.addToEnvironment(environment);
|
||||
ConfigDataEnvironmentPostProcessor.applyTo(environment, applicationContext);
|
||||
DefaultBootstrapRegisty bootstrapRegistry = new DefaultBootstrapRegisty();
|
||||
ConfigDataEnvironmentPostProcessor.applyTo(environment, applicationContext, bootstrapRegistry);
|
||||
bootstrapRegistry.applicationContextPrepared(applicationContext);
|
||||
DefaultPropertiesPropertySource.moveToEnd(environment);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user