|
29 | 29 | import org.springframework.boot.SpringApplication;
|
30 | 30 | import org.springframework.boot.env.EnvironmentPostProcessor;
|
31 | 31 | import org.springframework.boot.logging.DeferredLogFactory;
|
32 |
| -import org.springframework.boot.util.Instantiator; |
33 | 32 | import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration;
|
34 | 33 | import org.springframework.cloud.context.config.ContextRefreshedWithApplicationEvent;
|
35 | 34 | import org.springframework.cloud.context.scope.refresh.RefreshScope;
|
@@ -77,17 +76,12 @@ protected void updateEnvironment() {
|
77 | 76 | // decrypt happen after refresh. The hard coded call to
|
78 | 77 | // ConfigDataEnvironmentPostProcessor.applyTo() is now automated as well.
|
79 | 78 | 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); |
| 79 | + SpringFactoriesLoader.ArgumentResolver argumentResolver = SpringFactoriesLoader.ArgumentResolver.of(DeferredLogFactory.class, logFactory); |
| 80 | + argumentResolver = argumentResolver.and(ConfigurableBootstrapContext.class, bootstrapContext); |
| 81 | + argumentResolver = argumentResolver.and(BootstrapContext.class, bootstrapContext); |
| 82 | + argumentResolver = argumentResolver.and(BootstrapRegistry.class, bootstrapContext); |
| 83 | + SpringFactoriesLoader loader = SpringFactoriesLoader.forDefaultResourceLocation(getClass().getClassLoader()); |
| 84 | + List<EnvironmentPostProcessor> postProcessors = loader.load(EnvironmentPostProcessor.class, argumentResolver); |
91 | 85 | for (EnvironmentPostProcessor postProcessor : postProcessors) {
|
92 | 86 | postProcessor.postProcessEnvironment(environment, application);
|
93 | 87 | }
|
|
0 commit comments