camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lburgazz...@apache.org
Subject camel git commit: Minor improvement for spring-cloud's ServiceCall
Date Tue, 31 Jan 2017 07:09:03 GMT
Repository: camel
Updated Branches:
  refs/heads/master 6c984e110 -> 32a9aa974


Minor improvement for spring-cloud's ServiceCall


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/32a9aa97
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/32a9aa97
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/32a9aa97

Branch: refs/heads/master
Commit: 32a9aa9743aed2ff2efdb8454f441fa941b292e2
Parents: 6c984e1
Author: lburgazzoli <lburgazzoli@gmail.com>
Authored: Tue Jan 31 08:08:27 2017 +0100
Committer: lburgazzoli <lburgazzoli@gmail.com>
Committed: Tue Jan 31 08:08:27 2017 +0100

----------------------------------------------------------------------
 .../cloud/ServiceCallConfigurationProperties.java     |  9 +++++----
 .../ServiceCallServiceDiscoveryAutoConfiguration.java | 13 +++++++------
 .../ServiceCallServiceFilterAutoConfiguration.java    | 14 ++++++++------
 3 files changed, 20 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/32a9aa97/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/ServiceCallConfigurationProperties.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/ServiceCallConfigurationProperties.java
b/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/ServiceCallConfigurationProperties.java
index feeeb0d..d316dcb 100644
--- a/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/ServiceCallConfigurationProperties.java
+++ b/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/ServiceCallConfigurationProperties.java
@@ -18,6 +18,7 @@
 package org.apache.camel.spring.cloud;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -72,7 +73,7 @@ public class ServiceCallConfigurationProperties {
 
     public static class ServiceDiscovery {
         private boolean enabled = true;
-        private Map<String, String> services = new HashMap<>();
+        private Map<String, List<String>> services = new HashMap<>();
 
         public boolean isEnabled() {
             return enabled;
@@ -82,14 +83,14 @@ public class ServiceCallConfigurationProperties {
             this.enabled = enabled;
         }
 
-        public Map<String, String> getServices() {
+        public Map<String, List<String>> getServices() {
             return services;
         }
     }
 
     public static class ServiceFilter {
         private boolean enabled = true;
-        private Map<String, String> blacklist = new HashMap<>();
+        private Map<String, List<String>> blacklist = new HashMap<>();
 
         public boolean isEnabled() {
             return enabled;
@@ -99,7 +100,7 @@ public class ServiceCallConfigurationProperties {
             this.enabled = enabled;
         }
 
-        public Map<String, String> getBlacklist() {
+        public Map<String, List<String>> getBlacklist() {
             return blacklist;
         }
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/32a9aa97/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/ServiceCallServiceDiscoveryAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/ServiceCallServiceDiscoveryAutoConfiguration.java
b/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/ServiceCallServiceDiscoveryAutoConfiguration.java
index 4934465..055aa28 100644
--- a/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/ServiceCallServiceDiscoveryAutoConfiguration.java
+++ b/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/ServiceCallServiceDiscoveryAutoConfiguration.java
@@ -22,6 +22,7 @@ import java.util.Map;
 
 import org.apache.camel.cloud.ServiceDiscovery;
 import org.apache.camel.spring.boot.util.GroupCondition;
+import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.StringHelper;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.cloud.client.discovery.DiscoveryClient;
@@ -41,15 +42,15 @@ public class ServiceCallServiceDiscoveryAutoConfiguration {
     public DiscoveryClient serviceDiscoveryClient(ServiceCallConfigurationProperties properties)
{
         CamelCloudDiscoveryClient client = new CamelCloudDiscoveryClient("service-discovery-client");
 
-        Map<String, String> services = properties.getServiceDiscovery().getServices();
-        for (Map.Entry<String, String> entry : services.entrySet()) {
-
-            String[] parts = entry.getValue().split(",");
-            for (String part : parts) {
+        Map<String, List<String>> services = properties.getServiceDiscovery().getServices();
+        for (Map.Entry<String, List<String>> entry : services.entrySet()) {
+            for (String part : entry.getValue()) {
                 String host = StringHelper.before(part, ":");
                 String port = StringHelper.after(part, ":");
 
-                client.addServiceInstance(entry.getKey(), host, Integer.parseInt(port));
+                if (ObjectHelper.isNotEmpty(host) && ObjectHelper.isNotEmpty(port))
{
+                    client.addServiceInstance(entry.getKey(), host, Integer.parseInt(port));
+                }
             }
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/32a9aa97/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/ServiceCallServiceFilterAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/ServiceCallServiceFilterAutoConfiguration.java
b/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/ServiceCallServiceFilterAutoConfiguration.java
index cdcffc6..5f92678 100644
--- a/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/ServiceCallServiceFilterAutoConfiguration.java
+++ b/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/ServiceCallServiceFilterAutoConfiguration.java
@@ -17,6 +17,7 @@
 
 package org.apache.camel.spring.cloud;
 
+import java.util.List;
 import java.util.Map;
 
 import org.apache.camel.cloud.ServiceFilter;
@@ -24,6 +25,7 @@ import org.apache.camel.impl.cloud.BlacklistServiceFilter;
 import org.apache.camel.impl.cloud.ChainedServiceFilter;
 import org.apache.camel.impl.cloud.HealthyServiceFilter;
 import org.apache.camel.spring.boot.util.GroupCondition;
+import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.StringHelper;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.annotation.Bean;
@@ -42,15 +44,15 @@ public class ServiceCallServiceFilterAutoConfiguration {
     public ServiceFilter chainedServiceFilter(ServiceCallConfigurationProperties properties)
{
         BlacklistServiceFilter blacklist = new BlacklistServiceFilter();
 
-        Map<String, String> services = properties.getServiceFilter().getBlacklist();
-        for (Map.Entry<String, String> entry : services.entrySet()) {
-
-            String[] parts = entry.getValue().split(",");
-            for (String part : parts) {
+        Map<String, List<String>> services = properties.getServiceFilter().getBlacklist();
+        for (Map.Entry<String, List<String>> entry : services.entrySet()) {
+            for (String part : entry.getValue()) {
                 String host = StringHelper.before(part, ":");
                 String port = StringHelper.after(part, ":");
 
-                blacklist.addServer(entry.getKey(), host, Integer.parseInt(port));
+                if (ObjectHelper.isNotEmpty(host) && ObjectHelper.isNotEmpty(port))
{
+                    blacklist.addServer(entry.getKey(), host, Integer.parseInt(port));
+                }
             }
         }
 


Mime
View raw message