This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git


The following commit(s) were added to refs/heads/master by this push:
     new a140ebf  [SCB-2190] allow customer exclude servicecomb configuration 
mechanism (#2234)
a140ebf is described below

commit a140ebf04e9602649b114dc4fa65f6473d137028
Author: wujimin <[email protected]>
AuthorDate: Tue Feb 9 14:22:15 2021 +0800

    [SCB-2190] allow customer exclude servicecomb configuration mechanism 
(#2234)
---
 .../core/ConfigurationSpringInitializer.java       | 25 ++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git 
a/core/src/main/java/org/apache/servicecomb/core/ConfigurationSpringInitializer.java
 
b/core/src/main/java/org/apache/servicecomb/core/ConfigurationSpringInitializer.java
index afb8417..2fb562a 100644
--- 
a/core/src/main/java/org/apache/servicecomb/core/ConfigurationSpringInitializer.java
+++ 
b/core/src/main/java/org/apache/servicecomb/core/ConfigurationSpringInitializer.java
@@ -74,8 +74,17 @@ public class ConfigurationSpringInitializer extends 
PropertySourcesPlaceholderCo
 
   public static final String MAPPING_PROPERTY_SOURCE_NAME = "mapping.yaml";
 
-  private final List<BootStrapService> bootStrapServices =
-      SPIServiceUtils.getSortedService(BootStrapService.class);
+  public static final String EXTERNAL_INIT = "scb-config-external-init";
+
+  public static void setExternalInit(boolean value) {
+    System.setProperty(EXTERNAL_INIT, String.valueOf(value));
+  }
+
+  public static boolean isExternalInit() {
+    return Boolean.getBoolean(EXTERNAL_INIT);
+  }
+
+  private final List<BootStrapService> bootStrapServices = 
SPIServiceUtils.getSortedService(BootStrapService.class);
 
   public ConfigurationSpringInitializer() {
     setOrder(Ordered.LOWEST_PRECEDENCE / 2);
@@ -88,6 +97,11 @@ public class ConfigurationSpringInitializer extends 
PropertySourcesPlaceholderCo
    */
   @Override
   public void setEnvironment(Environment environment) {
+    super.setEnvironment(environment);
+    if (isExternalInit()) {
+      return;
+    }
+
     syncFromSpring(environment);
     syncToSpring(environment);
 
@@ -105,6 +119,10 @@ public class ConfigurationSpringInitializer extends 
PropertySourcesPlaceholderCo
   }
 
   public static void syncToSpring(Environment environment) {
+    if (isExternalInit()) {
+      return;
+    }
+
     addMicroserviceYAMLToSpring(environment);
     addMappingToSpring(environment);
   }
@@ -197,6 +215,9 @@ public class ConfigurationSpringInitializer extends 
PropertySourcesPlaceholderCo
   @Override
   protected Properties mergeProperties() throws IOException {
     Properties properties = super.mergeProperties();
+    if (isExternalInit()) {
+      return properties;
+    }
 
     AbstractConfiguration config = ConfigurationManager.getConfigInstance();
     Iterator<String> iterator = config.getKeys();

Reply via email to