[ 
https://issues.apache.org/jira/browse/SCB-636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16504099#comment-16504099
 ] 

ASF GitHub Bot commented on SCB-636:
------------------------------------

wujimin commented on a change in pull request #745: [SCB-636] change config 
mapping machanism
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/745#discussion_r193599910
 
 

 ##########
 File path: 
foundations/foundation-config/src/main/java/org/apache/servicecomb/config/ConfigMapping.java
 ##########
 @@ -17,20 +17,43 @@
 
 package org.apache.servicecomb.config;
 
-import java.io.InputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
 import java.util.LinkedHashMap;
+import java.util.List;
 import java.util.Map;
 
+import org.apache.commons.configuration.Configuration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * Created by   on 2017/1/5.
  */
 public final class ConfigMapping {
   private static Map<String, Object> configMap = null;
 
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(ConfigMapping.class);
+
   static {
     ClassLoader loader = Thread.currentThread().getContextClassLoader();
-    InputStream is = loader.getResourceAsStream("mapping.yaml");
-    configMap = YAMLUtil.yaml2Properties(is);
+    List<URL> urlList = new ArrayList<>();
+    configMap = new HashMap<String, Object>();
+    Enumeration<URL> urls;
+    try {
+      urls = loader.getResources("mapping.yaml");
+      while (urls.hasMoreElements()) {
+        urlList.add(urls.nextElement());
+      }
+      for (URL url : urlList) {
+        configMap.putAll(YAMLUtil.yaml2Properties(url.openStream()));
 
 Review comment:
   "snake yaml's demo and document don't require to close the stream"
   it's not a good idea to work in this way.
   
   1.YAMLUtil.yaml2Properties is our code
   2.if you are not sure if "yaml.loadAll" will close stream, it's better to 
read the source code, not guess

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> As a OM staff, i want to use the lb endpoint as the 
> servicecenter/configcenter address config
> ---------------------------------------------------------------------------------------------
>
>                 Key: SCB-636
>                 URL: https://issues.apache.org/jira/browse/SCB-636
>             Project: Apache ServiceComb
>          Issue Type: Improvement
>          Components: Java-Chassis
>            Reporter: jeho0815
>            Assignee: jeho0815
>            Priority: Major
>             Fix For: java-chassis-1.0.0-m2
>
>
> we want to deploy the servicecenter on PaaS platform and support a ELB to 
> access to sc/cc, so we can providor a adaptor to get the Endpoint to adapt 
> different Paas



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to