Commit 5a58e3d9 authored by liaozan's avatar liaozan 🏀

Add implements note for ConfigurablePropertiesLoader#load

parent 792f2539
...@@ -39,9 +39,12 @@ class ConfigurablePropertiesLoader { ...@@ -39,9 +39,12 @@ class ConfigurablePropertiesLoader {
this.log = deferredLogFactory.getLog(ConfigurablePropertiesLoader.class); this.log = deferredLogFactory.getLog(ConfigurablePropertiesLoader.class);
} }
/**
* Do not use asynchronous or thread pool to speed up configuration loading, as this may break the priority of configuration properties
*/
void load(ConfigurableEnvironment environment, SpringApplication application) { void load(ConfigurableEnvironment environment, SpringApplication application) {
List<ConfigurableProperties> configurableProperties = loadFactories(ConfigurableProperties.class, getClass().getClassLoader()); List<ConfigurableProperties> propertiesList = loadFactories(ConfigurableProperties.class, getClass().getClassLoader());
if (CollectionUtils.isEmpty(configurableProperties)) { if (CollectionUtils.isEmpty(propertiesList)) {
log.warn("There is no configuration properties found"); log.warn("There is no configuration properties found");
return; return;
} }
...@@ -49,15 +52,15 @@ class ConfigurablePropertiesLoader { ...@@ -49,15 +52,15 @@ class ConfigurablePropertiesLoader {
ApplicationEventMulticaster eventMulticaster = createEventMulticaster(application.getListeners()); ApplicationEventMulticaster eventMulticaster = createEventMulticaster(application.getListeners());
boolean remoteFirst = ApolloProperties.get(environment).isRemoteFirst(); boolean remoteFirst = ApolloProperties.get(environment).isRemoteFirst();
configurableProperties.parallelStream().forEach(properties -> { for (ConfigurableProperties properties : propertiesList) {
OrderedMapPropertySource propertySource = loadFromRemote(environment, remoteFirst, properties.getNamespace()); OrderedMapPropertySource propertySource = loadFromRemote(environment, remoteFirst, properties.getNamespace());
if (propertySource == null) { if (propertySource == null) {
return; continue;
} }
// multicast event // multicast event
ConfigLoadedEvent event = createEvent(environment, application, propertySource, properties); ConfigLoadedEvent event = createEvent(environment, application, propertySource, properties);
eventMulticaster.multicastEvent(event, ResolvableType.forClass(event.getClass())); eventMulticaster.multicastEvent(event, ResolvableType.forClass(event.getClass()));
}); }
} }
private OrderedMapPropertySource loadFromRemote(ConfigurableEnvironment environment, boolean remoteFirst, String namespace) { private OrderedMapPropertySource loadFromRemote(ConfigurableEnvironment environment, boolean remoteFirst, String namespace) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment