Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@

import org.springframework.boot.EnvironmentPostProcessor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.bootstrap.BootstrapContext;
import org.springframework.boot.bootstrap.BootstrapRegistry;
import org.springframework.boot.bootstrap.ConfigurableBootstrapContext;
import org.springframework.boot.bootstrap.DefaultBootstrapContext;
import org.springframework.boot.logging.DeferredLogFactory;
import org.springframework.boot.util.Instantiator;
import org.springframework.boot.support.EnvironmentPostProcessorsFactory;
import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration;
import org.springframework.cloud.context.config.ContextRefreshedWithApplicationEvent;
import org.springframework.cloud.context.scope.refresh.RefreshScope;
Expand All @@ -38,11 +36,11 @@
import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.PropertySource;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.io.support.SpringFactoriesLoader;

/**
* @author Dave Syer
* @author Venil Noronha
* @author Yanming Zhou
*/
public class ConfigDataContextRefresher extends ContextRefresher
implements ApplicationListener<ContextRefreshedWithApplicationEvent> {
Expand Down Expand Up @@ -77,17 +75,10 @@ protected void updateEnvironment() {
// decrypt happen after refresh. The hard coded call to
// ConfigDataEnvironmentPostProcessor.applyTo() is now automated as well.
DeferredLogFactory logFactory = new PassthruDeferredLogFactory();
List<String> classNames = SpringFactoriesLoader.loadFactoryNames(EnvironmentPostProcessor.class,
getClass().getClassLoader());
Instantiator<EnvironmentPostProcessor> instantiator = new Instantiator<>(EnvironmentPostProcessor.class,
(parameters) -> {
parameters.add(DeferredLogFactory.class, logFactory);
parameters.add(Log.class, logFactory::getLog);
parameters.add(ConfigurableBootstrapContext.class, bootstrapContext);
parameters.add(BootstrapContext.class, bootstrapContext);
parameters.add(BootstrapRegistry.class, bootstrapContext);
});
List<EnvironmentPostProcessor> postProcessors = instantiator.instantiate(classNames);
EnvironmentPostProcessorsFactory postProcessorsFactory = EnvironmentPostProcessorsFactory
.fromSpringFactories(getClass().getClassLoader());
List<EnvironmentPostProcessor> postProcessors = postProcessorsFactory.getEnvironmentPostProcessors(logFactory,
bootstrapContext);
for (EnvironmentPostProcessor postProcessor : postProcessors) {
postProcessor.postProcessEnvironment(environment, application);
}
Expand Down
Loading