|
|
@ -16,8 +16,8 @@ |
|
|
|
|
|
|
|
|
|
|
|
package org.springframework.cloud.context.refresh; |
|
|
|
package org.springframework.cloud.context.refresh; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.DefaultBootstrapContext; |
|
|
|
import org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor; |
|
|
|
import org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor; |
|
|
|
import org.springframework.boot.env.DefaultBootstrapRegisty; |
|
|
|
|
|
|
|
import org.springframework.cloud.context.scope.refresh.RefreshScope; |
|
|
|
import org.springframework.cloud.context.scope.refresh.RefreshScope; |
|
|
|
import org.springframework.context.ConfigurableApplicationContext; |
|
|
|
import org.springframework.context.ConfigurableApplicationContext; |
|
|
|
import org.springframework.core.env.MutablePropertySources; |
|
|
|
import org.springframework.core.env.MutablePropertySources; |
|
|
@ -31,8 +31,7 @@ import org.springframework.core.io.DefaultResourceLoader; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class ConfigDataContextRefresher extends ContextRefresher { |
|
|
|
public class ConfigDataContextRefresher extends ContextRefresher { |
|
|
|
|
|
|
|
|
|
|
|
public ConfigDataContextRefresher(ConfigurableApplicationContext context, |
|
|
|
public ConfigDataContextRefresher(ConfigurableApplicationContext context, RefreshScope scope) { |
|
|
|
RefreshScope scope) { |
|
|
|
|
|
|
|
super(context, scope); |
|
|
|
super(context, scope); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -44,14 +43,13 @@ public class ConfigDataContextRefresher extends ContextRefresher { |
|
|
|
StandardEnvironment environment = copyEnvironment(getContext().getEnvironment()); |
|
|
|
StandardEnvironment environment = copyEnvironment(getContext().getEnvironment()); |
|
|
|
String[] activeProfiles = getContext().getEnvironment().getActiveProfiles(); |
|
|
|
String[] activeProfiles = getContext().getEnvironment().getActiveProfiles(); |
|
|
|
DefaultResourceLoader resourceLoader = new DefaultResourceLoader(); |
|
|
|
DefaultResourceLoader resourceLoader = new DefaultResourceLoader(); |
|
|
|
ConfigDataEnvironmentPostProcessor.applyTo(environment, resourceLoader, |
|
|
|
ConfigDataEnvironmentPostProcessor.applyTo(environment, resourceLoader, new DefaultBootstrapContext(), |
|
|
|
new DefaultBootstrapRegisty(), activeProfiles); |
|
|
|
activeProfiles); |
|
|
|
|
|
|
|
|
|
|
|
if (environment.getPropertySources().contains(REFRESH_ARGS_PROPERTY_SOURCE)) { |
|
|
|
if (environment.getPropertySources().contains(REFRESH_ARGS_PROPERTY_SOURCE)) { |
|
|
|
environment.getPropertySources().remove(REFRESH_ARGS_PROPERTY_SOURCE); |
|
|
|
environment.getPropertySources().remove(REFRESH_ARGS_PROPERTY_SOURCE); |
|
|
|
} |
|
|
|
} |
|
|
|
MutablePropertySources target = getContext().getEnvironment() |
|
|
|
MutablePropertySources target = getContext().getEnvironment().getPropertySources(); |
|
|
|
.getPropertySources(); |
|
|
|
|
|
|
|
String targetName = null; |
|
|
|
String targetName = null; |
|
|
|
for (PropertySource<?> source : environment.getPropertySources()) { |
|
|
|
for (PropertySource<?> source : environment.getPropertySources()) { |
|
|
|
String name = source.getName(); |
|
|
|
String name = source.getName(); |
|
|
|