|
22 | 22 | import org.apache.commons.logging.Log;
|
23 | 23 | import org.apache.commons.logging.LogFactory;
|
24 | 24 |
|
25 |
| -import org.springframework.boot.BootstrapContext; |
26 |
| -import org.springframework.boot.BootstrapRegistry; |
27 | 25 | import org.springframework.boot.ConfigurableBootstrapContext;
|
28 | 26 | import org.springframework.boot.DefaultBootstrapContext;
|
29 | 27 | import org.springframework.boot.SpringApplication;
|
30 | 28 | import org.springframework.boot.env.EnvironmentPostProcessor;
|
| 29 | +import org.springframework.boot.env.EnvironmentPostProcessorsFactory; |
31 | 30 | import org.springframework.boot.logging.DeferredLogFactory;
|
32 |
| -import org.springframework.boot.util.Instantiator; |
33 | 31 | import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration;
|
34 | 32 | import org.springframework.cloud.context.config.ContextRefreshedWithApplicationEvent;
|
35 | 33 | import org.springframework.cloud.context.scope.refresh.RefreshScope;
|
|
38 | 36 | import org.springframework.core.env.MutablePropertySources;
|
39 | 37 | import org.springframework.core.env.PropertySource;
|
40 | 38 | import org.springframework.core.env.StandardEnvironment;
|
41 |
| -import org.springframework.core.io.support.SpringFactoriesLoader; |
42 | 39 |
|
43 | 40 | /**
|
44 | 41 | * @author Dave Syer
|
@@ -77,17 +74,8 @@ protected void updateEnvironment() {
|
77 | 74 | // decrypt happen after refresh. The hard coded call to
|
78 | 75 | // ConfigDataEnvironmentPostProcessor.applyTo() is now automated as well.
|
79 | 76 | DeferredLogFactory logFactory = new PassthruDeferredLogFactory();
|
80 |
| - List<String> classNames = SpringFactoriesLoader.loadFactoryNames(EnvironmentPostProcessor.class, |
81 |
| - getClass().getClassLoader()); |
82 |
| - Instantiator<EnvironmentPostProcessor> instantiator = new Instantiator<>(EnvironmentPostProcessor.class, |
83 |
| - (parameters) -> { |
84 |
| - parameters.add(DeferredLogFactory.class, logFactory); |
85 |
| - parameters.add(Log.class, logFactory::getLog); |
86 |
| - parameters.add(ConfigurableBootstrapContext.class, bootstrapContext); |
87 |
| - parameters.add(BootstrapContext.class, bootstrapContext); |
88 |
| - parameters.add(BootstrapRegistry.class, bootstrapContext); |
89 |
| - }); |
90 |
| - List<EnvironmentPostProcessor> postProcessors = instantiator.instantiate(classNames); |
| 77 | + EnvironmentPostProcessorsFactory environmentPostProcessorsFactory = EnvironmentPostProcessorsFactory.fromSpringFactories(getClass().getClassLoader()); |
| 78 | + List<EnvironmentPostProcessor> postProcessors = environmentPostProcessorsFactory.getEnvironmentPostProcessors(logFactory, bootstrapContext); |
91 | 79 | for (EnvironmentPostProcessor postProcessor : postProcessors) {
|
92 | 80 | postProcessor.postProcessEnvironment(environment, application);
|
93 | 81 | }
|
|
0 commit comments