You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2017/04/19 16:16:00 UTC

[1/4] camel git commit: Rename LoadBalancer to ServiceLoadBalancer to avoid confusion with LoadBalancer processor

Repository: camel
Updated Branches:
  refs/heads/master 56f2b24a2 -> 3e7b1cfdd


http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudLoadBalancerAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudLoadBalancerAutoConfiguration.java b/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudLoadBalancerAutoConfiguration.java
deleted file mode 100644
index d1c3a7f..0000000
--- a/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudLoadBalancerAutoConfiguration.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.spring.cloud;
-
-import org.apache.camel.cloud.LoadBalancer;
-import org.apache.camel.spring.boot.cloud.CamelCloudAutoConfiguration;
-import org.apache.camel.spring.boot.cloud.CamelCloudConfigurationProperties;
-import org.apache.camel.spring.boot.cloud.CamelCloudServiceDiscoveryAutoConfiguration;
-import org.apache.camel.spring.boot.util.GroupCondition;
-import org.springframework.boot.autoconfigure.AutoConfigureAfter;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration;
-import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Conditional;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-@ConditionalOnBean({ CamelCloudAutoConfiguration.class, LoadBalancerClient.class })
-@AutoConfigureAfter({ LoadBalancerAutoConfiguration.class, CamelCloudServiceDiscoveryAutoConfiguration.class })
-@EnableConfigurationProperties(CamelCloudConfigurationProperties.class)
-@Conditional(CamelSpringCloudLoadBalancerAutoConfiguration.LoadBalancerCondition.class)
-public class CamelSpringCloudLoadBalancerAutoConfiguration {
-
-    @Bean(name = "load-balancer")
-    @ConditionalOnMissingBean
-    public LoadBalancer cloudLoadBalancer(LoadBalancerClient loadBalancerClient) {
-        return new CamelSpringCloudLoadBalancer(loadBalancerClient);
-    }
-
-    // *******************************
-    // Condition
-    // *******************************
-
-    public static class LoadBalancerCondition extends GroupCondition {
-        public LoadBalancerCondition() {
-            super(
-                "camel.cloud",
-                "camel.cloud.load-balancer"
-            );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudServiceLoadBalancer.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudServiceLoadBalancer.java b/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudServiceLoadBalancer.java
new file mode 100644
index 0000000..50447f7
--- /dev/null
+++ b/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudServiceLoadBalancer.java
@@ -0,0 +1,81 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.cloud;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.cloud.ServiceDefinition;
+import org.apache.camel.cloud.ServiceLoadBalancer;
+import org.apache.camel.cloud.ServiceLoadBalancerFunction;
+import org.apache.camel.impl.cloud.DefaultServiceDefinition;
+import org.apache.camel.support.ServiceSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.cloud.client.ServiceInstance;
+import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
+
+public class CamelSpringCloudServiceLoadBalancer extends ServiceSupport implements CamelContextAware, ServiceLoadBalancer {
+    private static final Logger LOGGER = LoggerFactory.getLogger(CamelSpringCloudServiceLoadBalancer.class);
+
+    private final LoadBalancerClient loadBalancerClient;
+    private CamelContext camelContext;
+
+    public CamelSpringCloudServiceLoadBalancer(LoadBalancerClient loadBalancerClient) {
+        this.loadBalancerClient = loadBalancerClient;
+    }
+
+    @Override
+    public CamelContext getCamelContext() {
+        return camelContext;
+    }
+
+    @Override
+    public void setCamelContext(CamelContext camelContext) {
+        this.camelContext = camelContext;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        ObjectHelper.notNull(camelContext, "camelContext");
+        ObjectHelper.notNull(loadBalancerClient, "loadBalancerClient");
+
+        LOGGER.info("ServiceCall is using cloud load balancer of type: {}", loadBalancerClient.getClass());
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+    }
+
+    @Override
+    public <T> T process(String serviceName, ServiceLoadBalancerFunction<T> function) throws Exception {
+        return loadBalancerClient.execute(serviceName,  i -> function.apply(instanceToDefinition(i)));
+    }
+
+    // *******************************
+    // Helpers
+    // *******************************
+
+    private ServiceDefinition instanceToDefinition(ServiceInstance instance) {
+        return new DefaultServiceDefinition(
+            instance.getServiceId(),
+            instance.getHost(),
+            instance.getPort(),
+            instance.getMetadata()
+        );
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudServiceLoadBalancerAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudServiceLoadBalancerAutoConfiguration.java b/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudServiceLoadBalancerAutoConfiguration.java
new file mode 100644
index 0000000..eab3441
--- /dev/null
+++ b/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudServiceLoadBalancerAutoConfiguration.java
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.cloud;
+
+import org.apache.camel.cloud.ServiceLoadBalancer;
+import org.apache.camel.spring.boot.cloud.CamelCloudAutoConfiguration;
+import org.apache.camel.spring.boot.cloud.CamelCloudConfigurationProperties;
+import org.apache.camel.spring.boot.cloud.CamelCloudServiceDiscoveryAutoConfiguration;
+import org.apache.camel.spring.boot.util.GroupCondition;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration;
+import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Conditional;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@ConditionalOnBean({ CamelCloudAutoConfiguration.class, LoadBalancerClient.class })
+@AutoConfigureAfter({ LoadBalancerAutoConfiguration.class, CamelCloudServiceDiscoveryAutoConfiguration.class })
+@EnableConfigurationProperties(CamelCloudConfigurationProperties.class)
+@Conditional(CamelSpringCloudServiceLoadBalancerAutoConfiguration.LoadBalancerCondition.class)
+public class CamelSpringCloudServiceLoadBalancerAutoConfiguration {
+
+    @Bean(name = "load-balancer")
+    @ConditionalOnMissingBean
+    public ServiceLoadBalancer cloudLoadBalancer(LoadBalancerClient loadBalancerClient) {
+        return new CamelSpringCloudServiceLoadBalancer(loadBalancerClient);
+    }
+
+    // *******************************
+    // Condition
+    // *******************************
+
+    public static class LoadBalancerCondition extends GroupCondition {
+        public LoadBalancerCondition() {
+            super(
+                "camel.cloud",
+                "camel.cloud.load-balancer"
+            );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-spring-cloud/src/main/resources/META-INF/spring.factories
----------------------------------------------------------------------
diff --git a/components/camel-spring-cloud/src/main/resources/META-INF/spring.factories b/components/camel-spring-cloud/src/main/resources/META-INF/spring.factories
index fc59127..9de8f8b 100644
--- a/components/camel-spring-cloud/src/main/resources/META-INF/spring.factories
+++ b/components/camel-spring-cloud/src/main/resources/META-INF/spring.factories
@@ -16,4 +16,4 @@
 #
 
 org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-org.apache.camel.spring.cloud.CamelSpringCloudLoadBalancerAutoConfiguration
+org.apache.camel.spring.cloud.CamelSpringCloudServiceLoadBalancerAutoConfiguration

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-spring/src/test/java/org/apache/camel/spring/cloud/ServiceCallConfigurationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/cloud/ServiceCallConfigurationTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/cloud/ServiceCallConfigurationTest.java
index ed60528..556277e 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/cloud/ServiceCallConfigurationTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/cloud/ServiceCallConfigurationTest.java
@@ -20,7 +20,7 @@ import org.apache.camel.impl.cloud.ServiceCallConstants;
 import org.apache.camel.model.cloud.AggregatingServiceCallServiceDiscoveryConfiguration;
 import org.apache.camel.model.cloud.BlacklistServiceCallServiceFilterConfiguration;
 import org.apache.camel.model.cloud.ChainedServiceCallServiceFilterConfiguration;
-import org.apache.camel.model.cloud.DefaultServiceCallLoadBalancerConfiguration;
+import org.apache.camel.model.cloud.DefaultServiceCallServiceLoadBalancerConfiguration;
 import org.apache.camel.model.cloud.HealthyServiceCallServiceFilterConfiguration;
 import org.apache.camel.model.cloud.ServiceCallConfigurationDefinition;
 import org.apache.camel.model.cloud.ServiceCallExpressionConfiguration;
@@ -49,7 +49,7 @@ public class ServiceCallConfigurationTest {
         assertNotNull("No ServiceCallConfiguration (1)", conf);
         assertNotNull("No ServiceDiscoveryConfiguration (1)", conf.getServiceDiscoveryConfiguration());
         assertNotNull("No ServiceCallLoadBalancerConfiguration (1)", conf.getLoadBalancerConfiguration());
-        assertTrue(conf.getLoadBalancerConfiguration() instanceof DefaultServiceCallLoadBalancerConfiguration);
+        assertTrue(conf.getLoadBalancerConfiguration() instanceof DefaultServiceCallServiceLoadBalancerConfiguration);
 
         ServiceCallExpressionConfiguration expConf1 = conf.getExpressionConfiguration();
         assertNull(expConf1.getExpression());

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/RibbonServiceCallLoadBalancerConfigurationCommon.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/RibbonServiceCallLoadBalancerConfigurationCommon.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/RibbonServiceCallLoadBalancerConfigurationCommon.java
deleted file mode 100644
index d25dc3d..0000000
--- a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/RibbonServiceCallLoadBalancerConfigurationCommon.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.model.cloud.springboot;
-
-import java.util.Map;
-import javax.annotation.Generated;
-
-/**
- * Generated by camel-package-maven-plugin - do not edit this file!
- */
-@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
-public class RibbonServiceCallLoadBalancerConfigurationCommon {
-
-    /**
-     * The namespace
-     */
-    private String namespace;
-    /**
-     * The username
-     */
-    private String username;
-    /**
-     * The password
-     */
-    private String password;
-    /**
-     * Sets the Ribbon client name
-     */
-    private String clientName;
-    /**
-     * Set client properties to use. These properties are specific to what
-     * service call implementation are in use. For example if using ribbon then
-     * the client properties are define in
-     * com.netflix.client.config.CommonClientConfigKey.
-     */
-    private Map<String, String> properties;
-
-    public String getNamespace() {
-        return namespace;
-    }
-
-    public void setNamespace(String namespace) {
-        this.namespace = namespace;
-    }
-
-    public String getUsername() {
-        return username;
-    }
-
-    public void setUsername(String username) {
-        this.username = username;
-    }
-
-    public String getPassword() {
-        return password;
-    }
-
-    public void setPassword(String password) {
-        this.password = password;
-    }
-
-    public String getClientName() {
-        return clientName;
-    }
-
-    public void setClientName(String clientName) {
-        this.clientName = clientName;
-    }
-
-    public Map<String, String> getProperties() {
-        return properties;
-    }
-
-    public void setProperties(Map<String, String> properties) {
-        this.properties = properties;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/RibbonServiceCallLoadBalancerConfigurationProperties.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/RibbonServiceCallLoadBalancerConfigurationProperties.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/RibbonServiceCallLoadBalancerConfigurationProperties.java
deleted file mode 100644
index d0f230a..0000000
--- a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/RibbonServiceCallLoadBalancerConfigurationProperties.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.model.cloud.springboot;
-
-import java.util.HashMap;
-import java.util.Map;
-import javax.annotation.Generated;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-
-@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
-@ConfigurationProperties(prefix = "camel.cloud.ribbon.load-balancer")
-public class RibbonServiceCallLoadBalancerConfigurationProperties
-        extends
-            RibbonServiceCallLoadBalancerConfigurationCommon {
-
-    /**
-     * Enable the component
-     */
-    private boolean enabled = true;
-    /**
-     * Define additional configuration definitions
-     */
-    private Map<String, RibbonServiceCallLoadBalancerConfigurationCommon> configurations = new HashMap<>();
-
-    public Map<String, RibbonServiceCallLoadBalancerConfigurationCommon> getConfigurations() {
-        return configurations;
-    }
-
-    public boolean isEnabled() {
-        return enabled;
-    }
-
-    public void setEnabled(boolean enabled) {
-        this.enabled = enabled;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/RibbonServiceCallServiceLoadBalancerConfigurationCommon.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/RibbonServiceCallServiceLoadBalancerConfigurationCommon.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/RibbonServiceCallServiceLoadBalancerConfigurationCommon.java
new file mode 100644
index 0000000..ba78f35
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/RibbonServiceCallServiceLoadBalancerConfigurationCommon.java
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.model.cloud.springboot;
+
+import java.util.Map;
+import javax.annotation.Generated;
+
+/**
+ * Generated by camel-package-maven-plugin - do not edit this file!
+ */
+@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
+public class RibbonServiceCallServiceLoadBalancerConfigurationCommon {
+
+    /**
+     * The namespace
+     */
+    private String namespace;
+    /**
+     * The username
+     */
+    private String username;
+    /**
+     * The password
+     */
+    private String password;
+    /**
+     * Sets the Ribbon client name
+     */
+    private String clientName;
+    /**
+     * Set client properties to use. These properties are specific to what
+     * service call implementation are in use. For example if using ribbon then
+     * the client properties are define in
+     * com.netflix.client.config.CommonClientConfigKey.
+     */
+    private Map<String, String> properties;
+
+    public String getNamespace() {
+        return namespace;
+    }
+
+    public void setNamespace(String namespace) {
+        this.namespace = namespace;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public String getClientName() {
+        return clientName;
+    }
+
+    public void setClientName(String clientName) {
+        this.clientName = clientName;
+    }
+
+    public Map<String, String> getProperties() {
+        return properties;
+    }
+
+    public void setProperties(Map<String, String> properties) {
+        this.properties = properties;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/RibbonServiceCallServiceLoadBalancerConfigurationProperties.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/RibbonServiceCallServiceLoadBalancerConfigurationProperties.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/RibbonServiceCallServiceLoadBalancerConfigurationProperties.java
new file mode 100644
index 0000000..a670bf6
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/RibbonServiceCallServiceLoadBalancerConfigurationProperties.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.model.cloud.springboot;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.annotation.Generated;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
+@ConfigurationProperties(prefix = "camel.cloud.ribbon.load-balancer")
+public class RibbonServiceCallServiceLoadBalancerConfigurationProperties
+        extends
+            RibbonServiceCallServiceLoadBalancerConfigurationCommon {
+
+    /**
+     * Enable the component
+     */
+    private boolean enabled = true;
+    /**
+     * Define additional configuration definitions
+     */
+    private Map<String, RibbonServiceCallServiceLoadBalancerConfigurationCommon> configurations = new HashMap<>();
+
+    public Map<String, RibbonServiceCallServiceLoadBalancerConfigurationCommon> getConfigurations() {
+        return configurations;
+    }
+
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    public void setEnabled(boolean enabled) {
+        this.enabled = enabled;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/platforms/spring-boot/components-starter/camel-ribbon-starter/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-ribbon-starter/pom.xml b/platforms/spring-boot/components-starter/camel-ribbon-starter/pom.xml
index 24aba7b..6295637 100644
--- a/platforms/spring-boot/components-starter/camel-ribbon-starter/pom.xml
+++ b/platforms/spring-boot/components-starter/camel-ribbon-starter/pom.xml
@@ -55,5 +55,10 @@
       <artifactId>camel-spring-boot-starter</artifactId>
     </dependency>
     <!--END OF GENERATED CODE-->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-jetty</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/platforms/spring-boot/components-starter/camel-ribbon-starter/src/main/java/org/apache/camel/component/ribbon/springboot/cloud/RibbonCloudAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-ribbon-starter/src/main/java/org/apache/camel/component/ribbon/springboot/cloud/RibbonCloudAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-ribbon-starter/src/main/java/org/apache/camel/component/ribbon/springboot/cloud/RibbonCloudAutoConfiguration.java
index 8a58108..0135e07 100644
--- a/platforms/spring-boot/components-starter/camel-ribbon-starter/src/main/java/org/apache/camel/component/ribbon/springboot/cloud/RibbonCloudAutoConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-ribbon-starter/src/main/java/org/apache/camel/component/ribbon/springboot/cloud/RibbonCloudAutoConfiguration.java
@@ -21,10 +21,10 @@ import java.util.Map;
 import javax.annotation.PostConstruct;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.cloud.LoadBalancer;
-import org.apache.camel.component.ribbon.cloud.RibbonLoadBalancerFactory;
-import org.apache.camel.model.cloud.springboot.RibbonServiceCallLoadBalancerConfigurationCommon;
-import org.apache.camel.model.cloud.springboot.RibbonServiceCallLoadBalancerConfigurationProperties;
+import org.apache.camel.cloud.ServiceLoadBalancer;
+import org.apache.camel.component.ribbon.cloud.RibbonServiceLoadBalancerFactory;
+import org.apache.camel.model.cloud.springboot.RibbonServiceCallServiceLoadBalancerConfigurationCommon;
+import org.apache.camel.model.cloud.springboot.RibbonServiceCallServiceLoadBalancerConfigurationProperties;
 import org.apache.camel.spring.boot.CamelAutoConfiguration;
 import org.apache.camel.spring.boot.util.GroupCondition;
 import org.apache.camel.util.IntrospectionSupport;
@@ -44,20 +44,20 @@ import org.springframework.context.annotation.Lazy;
 @ConditionalOnBean(CamelAutoConfiguration.class)
 @Conditional(RibbonCloudAutoConfiguration.Condition.class)
 @AutoConfigureAfter(CamelAutoConfiguration.class)
-@EnableConfigurationProperties(RibbonServiceCallLoadBalancerConfigurationProperties.class)
+@EnableConfigurationProperties(RibbonServiceCallServiceLoadBalancerConfigurationProperties.class)
 public class RibbonCloudAutoConfiguration {
     @Autowired
     private CamelContext camelContext;
     @Autowired
-    private RibbonServiceCallLoadBalancerConfigurationProperties configuration;
+    private RibbonServiceCallServiceLoadBalancerConfigurationProperties configuration;
     @Autowired
     private ConfigurableBeanFactory beanFactory;
 
     @Lazy
     @Bean(name = "ribbon-load-balancer")
     @ConditionalOnClass(CamelContext.class)
-    public LoadBalancer configureLoadBalancerFactory() throws Exception {
-        RibbonLoadBalancerFactory factory = new RibbonLoadBalancerFactory();
+    public ServiceLoadBalancer configureLoadBalancerFactory() throws Exception {
+        RibbonServiceLoadBalancerFactory factory = new RibbonServiceLoadBalancerFactory();
 
         IntrospectionSupport.setProperties(
             camelContext,
@@ -73,12 +73,12 @@ public class RibbonCloudAutoConfiguration {
         if (beanFactory != null) {
             Map<String, Object> parameters = new HashMap<>();
 
-            for (Map.Entry<String, RibbonServiceCallLoadBalancerConfigurationCommon> entry : configuration.getConfigurations().entrySet()) {
+            for (Map.Entry<String, RibbonServiceCallServiceLoadBalancerConfigurationCommon> entry : configuration.getConfigurations().entrySet()) {
                 // clean up params
                 parameters.clear();
 
                 // The instance factory
-                RibbonLoadBalancerFactory factory = new RibbonLoadBalancerFactory();
+                RibbonServiceLoadBalancerFactory factory = new RibbonServiceLoadBalancerFactory();
 
                 try {
                     IntrospectionSupport.getProperties(entry.getValue(), parameters, null, false);

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/platforms/spring-boot/components-starter/camel-ribbon-starter/src/test/java/org/apache/camel/component/ribbon/springboot/cloud/RibbonLoadBalancerDisabledTest.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-ribbon-starter/src/test/java/org/apache/camel/component/ribbon/springboot/cloud/RibbonLoadBalancerDisabledTest.java b/platforms/spring-boot/components-starter/camel-ribbon-starter/src/test/java/org/apache/camel/component/ribbon/springboot/cloud/RibbonLoadBalancerDisabledTest.java
index e2e322f..082a8aa 100644
--- a/platforms/spring-boot/components-starter/camel-ribbon-starter/src/test/java/org/apache/camel/component/ribbon/springboot/cloud/RibbonLoadBalancerDisabledTest.java
+++ b/platforms/spring-boot/components-starter/camel-ribbon-starter/src/test/java/org/apache/camel/component/ribbon/springboot/cloud/RibbonLoadBalancerDisabledTest.java
@@ -18,8 +18,8 @@ package org.apache.camel.component.ribbon.springboot.cloud;
 
 import java.util.Map;
 
-import org.apache.camel.cloud.LoadBalancer;
-import org.apache.camel.model.cloud.springboot.RibbonServiceCallLoadBalancerConfigurationProperties;
+import org.apache.camel.cloud.ServiceLoadBalancer;
+import org.apache.camel.model.cloud.springboot.RibbonServiceCallServiceLoadBalancerConfigurationProperties;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -50,10 +50,10 @@ public class RibbonLoadBalancerDisabledTest {
     public void testConfiguration() throws Exception {
         Map<String, ?> beans;
 
-        beans = context.getBeansOfType(RibbonServiceCallLoadBalancerConfigurationProperties.class);
+        beans = context.getBeansOfType(RibbonServiceCallServiceLoadBalancerConfigurationProperties.class);
         Assert.assertTrue(beans.isEmpty());
 
-        beans = context.getBeansOfType(LoadBalancer.class);
+        beans = context.getBeansOfType(ServiceLoadBalancer.class);
         Assert.assertTrue(beans.isEmpty());
         Assert.assertFalse(beans.containsKey("ribbon-load-balancer"));
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/platforms/spring-boot/components-starter/camel-ribbon-starter/src/test/java/org/apache/camel/component/ribbon/springboot/cloud/RibbonLoadBalancerEnabledTest.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-ribbon-starter/src/test/java/org/apache/camel/component/ribbon/springboot/cloud/RibbonLoadBalancerEnabledTest.java b/platforms/spring-boot/components-starter/camel-ribbon-starter/src/test/java/org/apache/camel/component/ribbon/springboot/cloud/RibbonLoadBalancerEnabledTest.java
index b7e2780..9a25722 100644
--- a/platforms/spring-boot/components-starter/camel-ribbon-starter/src/test/java/org/apache/camel/component/ribbon/springboot/cloud/RibbonLoadBalancerEnabledTest.java
+++ b/platforms/spring-boot/components-starter/camel-ribbon-starter/src/test/java/org/apache/camel/component/ribbon/springboot/cloud/RibbonLoadBalancerEnabledTest.java
@@ -18,8 +18,8 @@ package org.apache.camel.component.ribbon.springboot.cloud;
 
 import java.util.Map;
 
-import org.apache.camel.cloud.LoadBalancer;
-import org.apache.camel.model.cloud.springboot.RibbonServiceCallLoadBalancerConfigurationProperties;
+import org.apache.camel.cloud.ServiceLoadBalancer;
+import org.apache.camel.model.cloud.springboot.RibbonServiceCallServiceLoadBalancerConfigurationProperties;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -50,11 +50,11 @@ public class RibbonLoadBalancerEnabledTest {
     public void testConfiguration() throws Exception {
         Map<String, ?> beans;
 
-        beans = context.getBeansOfType(RibbonServiceCallLoadBalancerConfigurationProperties.class);
+        beans = context.getBeansOfType(RibbonServiceCallServiceLoadBalancerConfigurationProperties.class);
         Assert.assertFalse(beans.isEmpty());
         Assert.assertEquals(1, beans.size());
 
-        beans = context.getBeansOfType(LoadBalancer.class);
+        beans = context.getBeansOfType(ServiceLoadBalancer.class);
         Assert.assertFalse(beans.isEmpty());
         Assert.assertTrue(beans.containsKey("ribbon-load-balancer"));
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/platforms/spring-boot/components-starter/camel-ribbon-starter/src/test/java/org/apache/camel/component/ribbon/springboot/cloud/RibbonLoadBalancerTest.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-ribbon-starter/src/test/java/org/apache/camel/component/ribbon/springboot/cloud/RibbonLoadBalancerTest.java b/platforms/spring-boot/components-starter/camel-ribbon-starter/src/test/java/org/apache/camel/component/ribbon/springboot/cloud/RibbonLoadBalancerTest.java
new file mode 100644
index 0000000..c021b00
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-ribbon-starter/src/test/java/org/apache/camel/component/ribbon/springboot/cloud/RibbonLoadBalancerTest.java
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ribbon.springboot.cloud;
+
+import java.util.Optional;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Navigate;
+import org.apache.camel.Processor;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.Route;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.ribbon.cloud.RibbonServiceLoadBalancer;
+import org.apache.camel.impl.cloud.DefaultServiceCallProcessor;
+import org.apache.camel.spring.boot.cloud.CamelCloudServiceDiscovery;
+import org.apache.camel.spring.boot.cloud.CamelCloudServiceFilter;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@DirtiesContext
+@SpringBootApplication
+@SpringBootTest(
+    classes = {
+        RibbonLoadBalancerTest.TestConfiguration.class
+    },
+    properties = {
+        "debug=false",
+        "camel.cloud.service-discovery.services[myService]=localhost:9090,localhost:9091",
+        "camel.cloud.ribbon.load-balancer.enabled=true"
+})
+public class RibbonLoadBalancerTest {
+    @Autowired
+    private CamelContext context;
+    @Autowired
+    private ProducerTemplate template;
+
+    @Test
+    public void testLoadBalancer() throws Exception {
+        DefaultServiceCallProcessor processor = findServiceCallProcessor();
+
+        Assert.assertNotNull(processor.getLoadBalancer());
+        Assert.assertTrue(processor.getLoadBalancer() instanceof RibbonServiceLoadBalancer);
+
+        RibbonServiceLoadBalancer loadBalancer = (RibbonServiceLoadBalancer)processor.getLoadBalancer();
+        Assert.assertTrue(loadBalancer.getServiceDiscovery() instanceof CamelCloudServiceDiscovery);
+        Assert.assertTrue(loadBalancer.getServiceFilter() instanceof CamelCloudServiceFilter);
+
+        Assert.assertEquals("9091", template.requestBody("direct:start", null, String.class));
+        Assert.assertEquals("9090", template.requestBody("direct:start", null, String.class));
+    }
+
+    @Configuration
+    public static class TestConfiguration {
+        @Bean
+        public RoutesBuilder routeBuilder() {
+            return new RouteBuilder() {
+                @Override
+                public void configure() throws Exception {
+                    from("direct:start")
+                        .routeId("scall")
+                        .serviceCall()
+                            .name("myService")
+                            .uri("jetty:http://myService")
+                            .end();
+                    from("jetty:http://localhost:9090").routeId("9090")
+                        .transform().constant("9090");
+                    from("jetty:http://localhost:9091").routeId("9091")
+                        .transform().constant("9091");
+                }
+            };
+        }
+    }
+
+    // ************************************
+    // Helpers
+    // ************************************
+
+    protected DefaultServiceCallProcessor findServiceCallProcessor() {
+        Route route = context.getRoute("scall");
+
+        Assert.assertNotNull("ServiceCall Route should be present", route);
+
+        return findServiceCallProcessor(route.navigate())
+            .orElseThrow(() -> new IllegalStateException("Unable to find a ServiceCallProcessor"));
+    }
+
+    protected Optional<DefaultServiceCallProcessor> findServiceCallProcessor(Navigate<Processor> navigate) {
+        for (Processor processor : navigate.next()) {
+            if (processor instanceof DefaultServiceCallProcessor) {
+                return Optional.ofNullable((DefaultServiceCallProcessor)processor);
+            }
+
+            if (processor instanceof Navigate) {
+                return findServiceCallProcessor((Navigate<Processor>)processor);
+            }
+        }
+
+        return Optional.empty();
+    }
+}


[2/4] camel git commit: Rename LoadBalancer to ServiceLoadBalancer to avoid confusion with LoadBalancer processor

Posted by lb...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceLoadBalancerConfiguration.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceLoadBalancerConfiguration.java b/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceLoadBalancerConfiguration.java
new file mode 100644
index 0000000..5c25f10
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceLoadBalancerConfiguration.java
@@ -0,0 +1,189 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.model.cloud;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.NoFactoryAvailableException;
+import org.apache.camel.cloud.ServiceLoadBalancer;
+import org.apache.camel.cloud.ServiceLoadBalancerFactory;
+import org.apache.camel.model.IdentifiedType;
+import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.PropertyDefinition;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.util.CamelContextHelper;
+import org.apache.camel.util.IntrospectionSupport;
+import org.apache.camel.util.ObjectHelper;
+
+@Metadata(label = "routing,cloud,load-balancing")
+@XmlRootElement(name = "loadBalancerConfiguration")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class ServiceCallServiceLoadBalancerConfiguration extends IdentifiedType implements ServiceLoadBalancerFactory {
+    private static final String RESOURCE_PATH = "META-INF/services/org/apache/camel/cloud/";
+
+    @XmlTransient
+    private final ServiceCallDefinition parent;
+    @XmlTransient
+    private final String factoryKey;
+    @XmlElement(name = "properties") @Metadata(label = "advanced")
+    private List<PropertyDefinition> properties;
+
+    public ServiceCallServiceLoadBalancerConfiguration() {
+        this(null, null);
+    }
+
+    public ServiceCallServiceLoadBalancerConfiguration(ServiceCallDefinition parent, String factoryKey) {
+        this.parent = parent;
+        this.factoryKey = factoryKey;
+    }
+
+    public ServiceCallDefinition end() {
+        return this.parent;
+    }
+
+    public ProcessorDefinition<?> endParent() {
+        return this.parent.end();
+    }
+
+    // *************************************************************************
+    //
+    // *************************************************************************
+
+    public List<PropertyDefinition> getProperties() {
+        return properties;
+    }
+
+    /**
+     * Set client properties to use.
+     * <p/>
+     * These properties are specific to what service call implementation are in
+     * use. For example if using ribbon, then the client properties are define
+     * in com.netflix.client.config.CommonClientConfigKey.
+     */
+    public void setProperties(List<PropertyDefinition> properties) {
+        this.properties = properties;
+    }
+
+    /**
+     * Adds a custom property to use.
+     * <p/>
+     * These properties are specific to what service call implementation are in
+     * use. For example if using ribbon, then the client properties are define
+     * in com.netflix.client.config.CommonClientConfigKey.
+     */
+    public ServiceCallServiceLoadBalancerConfiguration property(String key, String value) {
+        if (properties == null) {
+            properties = new ArrayList<>();
+        }
+        PropertyDefinition prop = new PropertyDefinition();
+        prop.setKey(key);
+        prop.setValue(value);
+        properties.add(prop);
+        return this;
+    }
+
+    protected Map<String, String> getPropertiesAsMap(CamelContext camelContext) throws Exception {
+        Map<String, String> answer;
+
+        if (properties == null || properties.isEmpty()) {
+            answer = Collections.emptyMap();
+        } else {
+            answer = new HashMap<>();
+            for (PropertyDefinition prop : properties) {
+                // support property placeholders
+                String key = CamelContextHelper.parseText(camelContext, prop.getKey());
+                String value = CamelContextHelper.parseText(camelContext, prop.getValue());
+                answer.put(key, value);
+            }
+        }
+
+        return answer;
+    }
+
+    // *************************************************************************
+    // Factory
+    // *************************************************************************
+
+    @Override
+    public ServiceLoadBalancer newInstance(CamelContext camelContext) throws Exception {
+        ObjectHelper.notNull(factoryKey, "LoadBalancer factoryKey");
+
+        ServiceLoadBalancer answer;
+
+        // First try to find the factory from the registry.
+        ServiceLoadBalancerFactory factory = CamelContextHelper.lookup(camelContext, factoryKey, ServiceLoadBalancerFactory.class);
+        if (factory != null) {
+            // If a factory is found in the registry do not re-configure it as
+            // it should be pre-configured.
+            answer = factory.newInstance(camelContext);
+        } else {
+
+            Class<?> type;
+            try {
+                // Then use Service factory.
+                type = camelContext.getFactoryFinder(RESOURCE_PATH).findClass(factoryKey);
+            } catch (Exception e) {
+                throw new NoFactoryAvailableException(RESOURCE_PATH + factoryKey, e);
+            }
+
+            if (type != null) {
+                if (ServiceLoadBalancerFactory.class.isAssignableFrom(type)) {
+                    factory = (ServiceLoadBalancerFactory) camelContext.getInjector().newInstance(type);
+                } else {
+                    throw new IllegalArgumentException(
+                        "Resolving LoadBalancer: " + factoryKey + " detected type conflict: Not a LoadBalancerFactory implementation. Found: " + type.getName());
+                }
+            }
+
+            try {
+                Map<String, Object> parameters = new HashMap<>();
+                IntrospectionSupport.getProperties(this, parameters, null, false);
+
+                // Convert properties to Map<String, String>
+                parameters.put("properties", getPropertiesAsMap(camelContext));
+
+                postProcessFactoryParameters(camelContext, parameters);
+
+                IntrospectionSupport.setProperties(factory, parameters);
+
+                answer = factory.newInstance(camelContext);
+            } catch (Exception e) {
+                throw new IllegalArgumentException(e);
+            }
+        }
+
+        return answer;
+    }
+
+    // *************************************************************************
+    // Utilities
+    // *************************************************************************
+
+    protected void postProcessFactoryParameters(CamelContext camelContext, Map<String, Object> parameters) throws Exception  {
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/resources/META-INF/services/org/apache/camel/cloud/default-load-balancer
----------------------------------------------------------------------
diff --git a/camel-core/src/main/resources/META-INF/services/org/apache/camel/cloud/default-load-balancer b/camel-core/src/main/resources/META-INF/services/org/apache/camel/cloud/default-load-balancer
deleted file mode 100644
index f8c9ddb..0000000
--- a/camel-core/src/main/resources/META-INF/services/org/apache/camel/cloud/default-load-balancer
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-class=org.apache.camel.impl.cloud.DefaultLoadBalancerFactory
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/resources/META-INF/services/org/apache/camel/cloud/default-service-load-balancer
----------------------------------------------------------------------
diff --git a/camel-core/src/main/resources/META-INF/services/org/apache/camel/cloud/default-service-load-balancer b/camel-core/src/main/resources/META-INF/services/org/apache/camel/cloud/default-service-load-balancer
new file mode 100644
index 0000000..16644c8
--- /dev/null
+++ b/camel-core/src/main/resources/META-INF/services/org/apache/camel/cloud/default-service-load-balancer
@@ -0,0 +1,17 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+class=org.apache.camel.impl.cloud.DefaultServiceLoadBalancerFactory
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/resources/org/apache/camel/model/cloud/jaxb.index
----------------------------------------------------------------------
diff --git a/camel-core/src/main/resources/org/apache/camel/model/cloud/jaxb.index b/camel-core/src/main/resources/org/apache/camel/model/cloud/jaxb.index
index 5f5af59..fb41af7 100644
--- a/camel-core/src/main/resources/org/apache/camel/model/cloud/jaxb.index
+++ b/camel-core/src/main/resources/org/apache/camel/model/cloud/jaxb.index
@@ -19,7 +19,7 @@ ServiceCallConfigurationDefinition
 ServiceCallServiceDiscoveryConfiguration
 ServiceCallServiceFilterConfiguration
 ServiceCallServiceChooserConfiguration
-ServiceCallLoadBalancerConfiguration
+ServiceCallServiceLoadBalancerConfiguration
 BlacklistServiceCallServiceFilterConfiguration
 ChainedServiceCallServiceFilterConfiguration
 PassThroughServiceCallServiceFilterConfiguration
@@ -31,4 +31,5 @@ HealthyServiceCallServiceFilterConfiguration
 KubernetesServiceCallServiceDiscoveryConfiguration
 AggregatingServiceCallServiceDiscoveryConfiguration
 StaticServiceCallServiceDiscoveryConfiguration
-RibbonServiceCallLoadBalancerConfiguration
+DefaultServiceCallServiceLoadBalancerConfiguration
+RibbonServiceCallServiceLoadBalancerConfiguration

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/test/java/org/apache/camel/impl/cloud/LoadBalancerTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/cloud/LoadBalancerTest.java b/camel-core/src/test/java/org/apache/camel/impl/cloud/LoadBalancerTest.java
index 5e17bfb..a78c291 100644
--- a/camel-core/src/test/java/org/apache/camel/impl/cloud/LoadBalancerTest.java
+++ b/camel-core/src/test/java/org/apache/camel/impl/cloud/LoadBalancerTest.java
@@ -30,7 +30,7 @@ public class LoadBalancerTest extends ContextTestSupport {
         serviceDiscovery.addServer("no-name", "127.0.0.1", 1001);
         serviceDiscovery.addServer("no-name", "127.0.0.1", 1002);
 
-        DefaultLoadBalancer loadBalancer = new DefaultLoadBalancer();
+        DefaultServiceLoadBalancer loadBalancer = new DefaultServiceLoadBalancer();
         loadBalancer.setCamelContext(context);
         loadBalancer.setServiceDiscovery(serviceDiscovery);
         loadBalancer.setServiceFilter(services -> services.stream().filter(s -> s.getPort() < 2000).collect(Collectors.toList()));

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/test/java/org/apache/camel/impl/cloud/ServiceCallConfigurationTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/cloud/ServiceCallConfigurationTest.java b/camel-core/src/test/java/org/apache/camel/impl/cloud/ServiceCallConfigurationTest.java
index e193c6e..155bcc0 100644
--- a/camel-core/src/test/java/org/apache/camel/impl/cloud/ServiceCallConfigurationTest.java
+++ b/camel-core/src/test/java/org/apache/camel/impl/cloud/ServiceCallConfigurationTest.java
@@ -68,9 +68,9 @@ public class ServiceCallConfigurationTest {
         DefaultServiceCallProcessor proc = findServiceCallProcessor(context.getRoute("default"));
 
         Assert.assertNotNull(proc);
-        Assert.assertTrue(proc.getLoadBalancer() instanceof DefaultLoadBalancer);
+        Assert.assertTrue(proc.getLoadBalancer() instanceof DefaultServiceLoadBalancer);
 
-        DefaultLoadBalancer loadBalancer = (DefaultLoadBalancer)proc.getLoadBalancer();
+        DefaultServiceLoadBalancer loadBalancer = (DefaultServiceLoadBalancer)proc.getLoadBalancer();
         Assert.assertEquals(sd, loadBalancer.getServiceDiscovery());
         Assert.assertEquals(sf, loadBalancer.getServiceFilter());
 
@@ -111,9 +111,9 @@ public class ServiceCallConfigurationTest {
         DefaultServiceCallProcessor proc = findServiceCallProcessor(context.getRoute("default"));
 
         Assert.assertNotNull(proc);
-        Assert.assertTrue(proc.getLoadBalancer() instanceof DefaultLoadBalancer);
+        Assert.assertTrue(proc.getLoadBalancer() instanceof DefaultServiceLoadBalancer);
 
-        DefaultLoadBalancer loadBalancer = (DefaultLoadBalancer)proc.getLoadBalancer();
+        DefaultServiceLoadBalancer loadBalancer = (DefaultServiceLoadBalancer)proc.getLoadBalancer();
         Assert.assertEquals(sd, loadBalancer.getServiceDiscovery());
         Assert.assertEquals(sf, loadBalancer.getServiceFilter());
 
@@ -155,9 +155,9 @@ public class ServiceCallConfigurationTest {
         DefaultServiceCallProcessor proc = findServiceCallProcessor(context.getRoute("default"));
 
         Assert.assertNotNull(proc);
-        Assert.assertTrue(proc.getLoadBalancer() instanceof DefaultLoadBalancer);
+        Assert.assertTrue(proc.getLoadBalancer() instanceof DefaultServiceLoadBalancer);
 
-        DefaultLoadBalancer loadBalancer = (DefaultLoadBalancer)proc.getLoadBalancer();
+        DefaultServiceLoadBalancer loadBalancer = (DefaultServiceLoadBalancer)proc.getLoadBalancer();
         Assert.assertEquals(sd, loadBalancer.getServiceDiscovery());
         Assert.assertEquals(sf, loadBalancer.getServiceFilter());
 
@@ -236,9 +236,9 @@ public class ServiceCallConfigurationTest {
             DefaultServiceCallProcessor proc = findServiceCallProcessor(context.getRoute("default"));
 
             Assert.assertNotNull(proc);
-            Assert.assertTrue(proc.getLoadBalancer() instanceof DefaultLoadBalancer);
+            Assert.assertTrue(proc.getLoadBalancer() instanceof DefaultServiceLoadBalancer);
 
-            DefaultLoadBalancer loadBalancer = (DefaultLoadBalancer) proc.getLoadBalancer();
+            DefaultServiceLoadBalancer loadBalancer = (DefaultServiceLoadBalancer) proc.getLoadBalancer();
             Assert.assertEquals(defaultServiceDiscovery, loadBalancer.getServiceDiscovery());
             Assert.assertEquals(defaultServiceFilter, loadBalancer.getServiceFilter());
         }
@@ -248,9 +248,9 @@ public class ServiceCallConfigurationTest {
             DefaultServiceCallProcessor proc = findServiceCallProcessor(context.getRoute("named"));
 
             Assert.assertNotNull(proc);
-            Assert.assertTrue(proc.getLoadBalancer() instanceof DefaultLoadBalancer);
+            Assert.assertTrue(proc.getLoadBalancer() instanceof DefaultServiceLoadBalancer);
 
-            DefaultLoadBalancer loadBalancer = (DefaultLoadBalancer) proc.getLoadBalancer();
+            DefaultServiceLoadBalancer loadBalancer = (DefaultServiceLoadBalancer) proc.getLoadBalancer();
             Assert.assertEquals(defaultServiceDiscovery, loadBalancer.getServiceDiscovery());
             Assert.assertEquals(namedServiceFilter, loadBalancer.getServiceFilter());
         }
@@ -260,9 +260,9 @@ public class ServiceCallConfigurationTest {
             DefaultServiceCallProcessor proc = findServiceCallProcessor(context.getRoute("local"));
 
             Assert.assertNotNull(proc);
-            Assert.assertTrue(proc.getLoadBalancer() instanceof DefaultLoadBalancer);
+            Assert.assertTrue(proc.getLoadBalancer() instanceof DefaultServiceLoadBalancer);
 
-            DefaultLoadBalancer loadBalancer = (DefaultLoadBalancer) proc.getLoadBalancer();
+            DefaultServiceLoadBalancer loadBalancer = (DefaultServiceLoadBalancer) proc.getLoadBalancer();
             Assert.assertEquals(localServiceDiscovery, loadBalancer.getServiceDiscovery());
             Assert.assertEquals(namedServiceFilter, loadBalancer.getServiceFilter());
         }
@@ -302,7 +302,7 @@ public class ServiceCallConfigurationTest {
             DefaultServiceCallProcessor proc = findServiceCallProcessor(context.getRoute("default"));
 
             Assert.assertNotNull(proc);
-            Assert.assertTrue(proc.getLoadBalancer() instanceof DefaultLoadBalancer);
+            Assert.assertTrue(proc.getLoadBalancer() instanceof DefaultServiceLoadBalancer);
             Assert.assertEquals("service-name", proc.getName());
             Assert.assertEquals("file", proc.getScheme());
             Assert.assertEquals("direct:service-name", proc.getUri());

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-consul/src/test/java/org/apache/camel/component/consul/cloud/SpringConsulDefaultServiceCallRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-consul/src/test/java/org/apache/camel/component/consul/cloud/SpringConsulDefaultServiceCallRouteTest.java b/components/camel-consul/src/test/java/org/apache/camel/component/consul/cloud/SpringConsulDefaultServiceCallRouteTest.java
index 05b28d7..4627984 100644
--- a/components/camel-consul/src/test/java/org/apache/camel/component/consul/cloud/SpringConsulDefaultServiceCallRouteTest.java
+++ b/components/camel-consul/src/test/java/org/apache/camel/component/consul/cloud/SpringConsulDefaultServiceCallRouteTest.java
@@ -17,6 +17,12 @@
 
 package org.apache.camel.component.consul.cloud;
 
+import java.util.List;
+
+import org.apache.camel.component.ribbon.cloud.RibbonServiceLoadBalancer;
+import org.apache.camel.impl.cloud.DefaultServiceCallProcessor;
+import org.junit.Assert;
+import org.junit.Test;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
@@ -25,4 +31,14 @@ public class SpringConsulDefaultServiceCallRouteTest extends SpringConsulService
     protected AbstractApplicationContext createApplicationContext() {
         return new ClassPathXmlApplicationContext("org/apache/camel/component/consul/cloud/SpringConsulDefaultServiceCallRouteTest.xml");
     }
+
+    @Test
+    public void testServiceCallConfiguration() throws Exception {
+        List<DefaultServiceCallProcessor> processors = findServiceCallProcessors();
+
+        Assert.assertFalse(processors.isEmpty());
+        Assert.assertEquals(2, processors.size());
+        Assert.assertFalse(processors.get(0).getLoadBalancer() instanceof RibbonServiceLoadBalancer);
+        Assert.assertFalse(processors.get(1).getLoadBalancer() instanceof RibbonServiceLoadBalancer);
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-consul/src/test/java/org/apache/camel/component/consul/cloud/SpringConsulExpressionServiceCallRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-consul/src/test/java/org/apache/camel/component/consul/cloud/SpringConsulExpressionServiceCallRouteTest.java b/components/camel-consul/src/test/java/org/apache/camel/component/consul/cloud/SpringConsulExpressionServiceCallRouteTest.java
index f7a4448..13cd719 100644
--- a/components/camel-consul/src/test/java/org/apache/camel/component/consul/cloud/SpringConsulExpressionServiceCallRouteTest.java
+++ b/components/camel-consul/src/test/java/org/apache/camel/component/consul/cloud/SpringConsulExpressionServiceCallRouteTest.java
@@ -17,6 +17,12 @@
 
 package org.apache.camel.component.consul.cloud;
 
+import java.util.List;
+
+import org.apache.camel.component.ribbon.cloud.RibbonServiceLoadBalancer;
+import org.apache.camel.impl.cloud.DefaultServiceCallProcessor;
+import org.junit.Assert;
+import org.junit.Test;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
@@ -25,4 +31,14 @@ public class SpringConsulExpressionServiceCallRouteTest extends SpringConsulServ
     protected AbstractApplicationContext createApplicationContext() {
         return new ClassPathXmlApplicationContext("org/apache/camel/component/consul/cloud/SpringConsulExpressionServiceCallRouteTest.xml");
     }
+
+    @Test
+    public void testServiceCallConfiguration() throws Exception {
+        List<DefaultServiceCallProcessor> processors = findServiceCallProcessors();
+
+        Assert.assertFalse(processors.isEmpty());
+        Assert.assertEquals(2, processors.size());
+        Assert.assertFalse(processors.get(0).getLoadBalancer() instanceof RibbonServiceLoadBalancer);
+        Assert.assertFalse(processors.get(1).getLoadBalancer() instanceof RibbonServiceLoadBalancer);
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-consul/src/test/java/org/apache/camel/component/consul/cloud/SpringConsulRibbonServiceCallRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-consul/src/test/java/org/apache/camel/component/consul/cloud/SpringConsulRibbonServiceCallRouteTest.java b/components/camel-consul/src/test/java/org/apache/camel/component/consul/cloud/SpringConsulRibbonServiceCallRouteTest.java
index 70eebfb..f76e72e 100644
--- a/components/camel-consul/src/test/java/org/apache/camel/component/consul/cloud/SpringConsulRibbonServiceCallRouteTest.java
+++ b/components/camel-consul/src/test/java/org/apache/camel/component/consul/cloud/SpringConsulRibbonServiceCallRouteTest.java
@@ -17,6 +17,12 @@
 
 package org.apache.camel.component.consul.cloud;
 
+import java.util.List;
+
+import org.apache.camel.component.ribbon.cloud.RibbonServiceLoadBalancer;
+import org.apache.camel.impl.cloud.DefaultServiceCallProcessor;
+import org.junit.Assert;
+import org.junit.Test;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
@@ -25,4 +31,14 @@ public class SpringConsulRibbonServiceCallRouteTest extends SpringConsulServiceC
     protected AbstractApplicationContext createApplicationContext() {
         return new ClassPathXmlApplicationContext("org/apache/camel/component/consul/cloud/SpringConsulRibbonServiceCallRouteTest.xml");
     }
+
+    @Test
+    public void testServiceCallConfiguration() throws Exception {
+        List<DefaultServiceCallProcessor> processors = findServiceCallProcessors();
+
+        Assert.assertFalse(processors.isEmpty());
+        Assert.assertEquals(2, processors.size());
+        Assert.assertTrue(processors.get(0).getLoadBalancer() instanceof RibbonServiceLoadBalancer);
+        Assert.assertTrue(processors.get(1).getLoadBalancer() instanceof RibbonServiceLoadBalancer);
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-consul/src/test/java/org/apache/camel/component/consul/cloud/SpringConsulServiceCallRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-consul/src/test/java/org/apache/camel/component/consul/cloud/SpringConsulServiceCallRouteTest.java b/components/camel-consul/src/test/java/org/apache/camel/component/consul/cloud/SpringConsulServiceCallRouteTest.java
index ac10b06..335c61e 100644
--- a/components/camel-consul/src/test/java/org/apache/camel/component/consul/cloud/SpringConsulServiceCallRouteTest.java
+++ b/components/camel-consul/src/test/java/org/apache/camel/component/consul/cloud/SpringConsulServiceCallRouteTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.camel.component.consul.cloud;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
@@ -24,7 +25,14 @@ import com.orbitz.consul.AgentClient;
 import com.orbitz.consul.Consul;
 import com.orbitz.consul.model.agent.ImmutableRegistration;
 import com.orbitz.consul.model.agent.Registration;
+import org.apache.camel.Navigate;
+import org.apache.camel.Processor;
+import org.apache.camel.Route;
+import org.apache.camel.impl.cloud.DefaultServiceCallProcessor;
+import org.apache.camel.processor.ChoiceProcessor;
+import org.apache.camel.processor.FilterProcessor;
 import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.junit.Assert;
 import org.junit.Test;
 
 public abstract class SpringConsulServiceCallRouteTest extends CamelSpringTestSupport {
@@ -105,4 +113,33 @@ public abstract class SpringConsulServiceCallRouteTest extends CamelSpringTestSu
 
         assertMockEndpointsSatisfied();
     }
+
+    // ************************************
+    // Helpers
+    // ************************************
+
+    protected List<DefaultServiceCallProcessor> findServiceCallProcessors() {
+        Route route = context().getRoute("scall");
+
+        Assert.assertNotNull("ServiceCall Route should be present", route);
+
+        return findServiceCallProcessors(new ArrayList<>(), route.navigate());
+    }
+
+    protected List<DefaultServiceCallProcessor> findServiceCallProcessors(List<DefaultServiceCallProcessor> processors, Navigate<Processor> navigate) {
+        for (Processor processor : navigate.next()) {
+            if (processor instanceof DefaultServiceCallProcessor) {
+                processors.add((DefaultServiceCallProcessor)processor);
+            }
+            if (processor instanceof ChoiceProcessor) {
+                for (FilterProcessor filter : ((ChoiceProcessor) processor).getFilters()) {
+                    findServiceCallProcessors(processors, filter);
+                }
+            } else if (processor instanceof Navigate) {
+                return findServiceCallProcessors(processors, (Navigate<Processor>)processor);
+            }
+        }
+
+        return processors;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-consul/src/test/resources/org/apache/camel/component/consul/cloud/SpringConsulDefaultServiceCallRouteTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-consul/src/test/resources/org/apache/camel/component/consul/cloud/SpringConsulDefaultServiceCallRouteTest.xml b/components/camel-consul/src/test/resources/org/apache/camel/component/consul/cloud/SpringConsulDefaultServiceCallRouteTest.xml
index f050001..5e8731e 100644
--- a/components/camel-consul/src/test/resources/org/apache/camel/component/consul/cloud/SpringConsulDefaultServiceCallRouteTest.xml
+++ b/components/camel-consul/src/test/resources/org/apache/camel/component/consul/cloud/SpringConsulDefaultServiceCallRouteTest.xml
@@ -51,7 +51,7 @@
     <!-- Routes                                -->
     <!-- ************************************* -->
 
-    <route>
+    <route id="scall">
       <from uri="direct:start"/>
       <choice>
         <when>

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-consul/src/test/resources/org/apache/camel/component/consul/cloud/SpringConsulExpressionServiceCallRouteTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-consul/src/test/resources/org/apache/camel/component/consul/cloud/SpringConsulExpressionServiceCallRouteTest.xml b/components/camel-consul/src/test/resources/org/apache/camel/component/consul/cloud/SpringConsulExpressionServiceCallRouteTest.xml
index 9b463f8..a31e545 100644
--- a/components/camel-consul/src/test/resources/org/apache/camel/component/consul/cloud/SpringConsulExpressionServiceCallRouteTest.xml
+++ b/components/camel-consul/src/test/resources/org/apache/camel/component/consul/cloud/SpringConsulExpressionServiceCallRouteTest.xml
@@ -54,7 +54,7 @@
     <!-- Routes                                -->
     <!-- ************************************* -->
 
-    <route>
+    <route id="scall">
       <from uri="direct:start"/>
       <choice>
         <when>

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-consul/src/test/resources/org/apache/camel/component/consul/cloud/SpringConsulRibbonServiceCallRouteTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-consul/src/test/resources/org/apache/camel/component/consul/cloud/SpringConsulRibbonServiceCallRouteTest.xml b/components/camel-consul/src/test/resources/org/apache/camel/component/consul/cloud/SpringConsulRibbonServiceCallRouteTest.xml
index 582ccee..5af397c 100644
--- a/components/camel-consul/src/test/resources/org/apache/camel/component/consul/cloud/SpringConsulRibbonServiceCallRouteTest.xml
+++ b/components/camel-consul/src/test/resources/org/apache/camel/component/consul/cloud/SpringConsulRibbonServiceCallRouteTest.xml
@@ -51,7 +51,7 @@
     <!-- Routes                                -->
     <!-- ************************************* -->
 
-    <route>
+    <route id="scall">
       <from uri="direct:start"/>
       <choice>
         <when>

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdConfiguration.java b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdConfiguration.java
index e784fa5..b8e7c81 100644
--- a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdConfiguration.java
+++ b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdConfiguration.java
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.component.etcd;
 
+import mousio.etcd4j.EtcdClient;
+import mousio.etcd4j.EtcdSecurityContext;
+
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelContextAware;
 import org.apache.camel.RuntimeCamelException;
@@ -23,9 +26,6 @@ import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
 import org.apache.camel.util.jsse.SSLContextParameters;
 
-import mousio.etcd4j.EtcdClient;
-import mousio.etcd4j.EtcdSecurityContext;
-
 @UriParams
 public class EtcdConfiguration implements CamelContextAware, Cloneable {
 

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/cloud/RibbonLoadBalancer.java
----------------------------------------------------------------------
diff --git a/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/cloud/RibbonLoadBalancer.java b/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/cloud/RibbonLoadBalancer.java
deleted file mode 100644
index 759a602..0000000
--- a/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/cloud/RibbonLoadBalancer.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.camel.component.ribbon.cloud;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.RejectedExecutionException;
-
-import com.netflix.client.config.IClientConfig;
-import com.netflix.client.config.IClientConfigKey;
-import com.netflix.loadbalancer.DummyPing;
-import com.netflix.loadbalancer.ILoadBalancer;
-import com.netflix.loadbalancer.PollingServerListUpdater;
-import com.netflix.loadbalancer.RoundRobinRule;
-import com.netflix.loadbalancer.Server;
-import com.netflix.loadbalancer.ServerList;
-import com.netflix.loadbalancer.ZoneAwareLoadBalancer;
-import org.apache.camel.CamelContext;
-import org.apache.camel.CamelContextAware;
-import org.apache.camel.cloud.LoadBalancer;
-import org.apache.camel.cloud.LoadBalancerFunction;
-import org.apache.camel.cloud.ServiceDefinition;
-import org.apache.camel.cloud.ServiceDiscovery;
-import org.apache.camel.cloud.ServiceDiscoveryAware;
-import org.apache.camel.cloud.ServiceFilter;
-import org.apache.camel.cloud.ServiceFilterAware;
-import org.apache.camel.component.ribbon.RibbonConfiguration;
-import org.apache.camel.support.ServiceSupport;
-import org.apache.camel.util.ObjectHelper;
-import org.apache.camel.util.ServiceHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RibbonLoadBalancer
-        extends ServiceSupport
-        implements CamelContextAware, ServiceDiscoveryAware, ServiceFilterAware, LoadBalancer {
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(RibbonLoadBalancer.class);
-
-    private final RibbonConfiguration configuration;
-    private final ConcurrentMap<String, ZoneAwareLoadBalancer<RibbonServiceDefinition>> loadBalancers;
-    private CamelContext camelContext;
-    private ServiceDiscovery serviceDiscovery;
-    private ServiceFilter serviceFilter;
-
-    public RibbonLoadBalancer(RibbonConfiguration configuration) {
-        this.configuration = configuration;
-        this.loadBalancers = new ConcurrentHashMap<>();
-    }
-
-    @Override
-    public CamelContext getCamelContext() {
-        return camelContext;
-    }
-
-    @Override
-    public void setCamelContext(CamelContext camelContext) {
-        this.camelContext = camelContext;
-    }
-
-    @Override
-    public ServiceDiscovery getServiceDiscovery() {
-        return serviceDiscovery;
-    }
-
-    @Override
-    public void setServiceDiscovery(ServiceDiscovery serviceDiscovery) {
-        this.serviceDiscovery = serviceDiscovery;
-    }
-
-    @Override
-    public ServiceFilter getServiceFilter() {
-        return serviceFilter;
-    }
-
-    @Override
-    public void setServiceFilter(ServiceFilter serviceFilter) {
-        this.serviceFilter = serviceFilter;
-    }
-
-    // ************************
-    // lifecycle
-    // ************************
-
-    @Override
-    protected void doStart() throws Exception {
-        ObjectHelper.notNull(configuration, "configuration");
-        ObjectHelper.notNull(camelContext, "camel context");
-
-        if (serviceDiscovery != null) {
-            LOGGER.info("ServiceCall is using ribbon load balancer with service discovery type: {} and service filter: {}",
-                serviceDiscovery.getClass(),
-                serviceDiscovery != null ? serviceFilter.getClass() : "none");
-        } else {
-            LOGGER.info("ServiceCall is using ribbon load balancer");
-        }
-
-        ServiceHelper.startService(serviceDiscovery);
-    }
-
-    @Override
-    protected void doStop() throws Exception {
-        loadBalancers.values().forEach(ZoneAwareLoadBalancer::stopServerListRefreshing);
-        loadBalancers.clear();
-
-        ServiceHelper.stopService(serviceDiscovery);
-    }
-
-    // ************************
-    // Processor
-    // ************************
-
-    @Override
-    public <T> T process(String serviceName, LoadBalancerFunction<T> request) throws Exception {
-        ILoadBalancer loadBalancer = loadBalancers.computeIfAbsent(serviceName, key -> createLoadBalancer(key));
-        Server server = loadBalancer.chooseServer(serviceName);
-
-        if (server == null) {
-            throw new RejectedExecutionException("No active services with name " + serviceName);
-        }
-
-        ServiceDefinition definition;
-
-        if (server instanceof ServiceDefinition) {
-            // If the service discovery is one of camel provides, the definition
-            // is already of the expected type.
-            definition = (ServiceDefinition)server;
-        } else {
-            // If ribbon server list is configured through client config properties
-            // i.e. with listOfServers property the instance provided by the load
-            // balancer is of type Server so a conversion is needed
-            definition = new RibbonServiceDefinition(
-                serviceName,
-                server.getHost(),
-                server.getPort()
-            );
-
-            String zone = server.getZone();
-            if (zone != null) {
-                server.setZone(zone);
-            }
-        }
-
-        return request.apply(definition);
-    }
-
-    // ************************
-    // Helpers
-    // ************************
-
-    private ZoneAwareLoadBalancer<RibbonServiceDefinition> createLoadBalancer(String serviceName) {
-        // setup client config
-        IClientConfig config = configuration.getClientName() != null
-            ? IClientConfig.Builder.newBuilder(configuration.getClientName()).build()
-            : IClientConfig.Builder.newBuilder().build();
-
-        if (configuration.getProperties() != null) {
-            for (Map.Entry<String, String> entry : configuration.getProperties().entrySet()) {
-                IClientConfigKey key = IClientConfigKey.Keys.valueOf(entry.getKey());
-                String value = entry.getValue();
-
-                LOGGER.debug("RibbonClientConfig: {}={}", key.key(), value);
-                config.set(key, value);
-            }
-        }
-
-        ZoneAwareLoadBalancer<RibbonServiceDefinition> loadBalancer;
-
-        if (serviceDiscovery != null) {
-            loadBalancer = new ZoneAwareLoadBalancer<>(
-                config,
-                configuration.getRuleOrDefault(RoundRobinRule::new),
-                configuration.getPingOrDefault(DummyPing::new),
-                new RibbonServerList(serviceName, serviceDiscovery, serviceFilter),
-                null,
-                new PollingServerListUpdater(config));
-        } else {
-            loadBalancer = new ZoneAwareLoadBalancer<>(config);
-        }
-
-        return loadBalancer;
-    }
-
-    static final class RibbonServerList implements ServerList<RibbonServiceDefinition>  {
-        private final String serviceName;
-        private final ServiceDiscovery serviceDiscovery;
-        private final ServiceFilter serviceFilter;
-
-        RibbonServerList(String serviceName, ServiceDiscovery serviceDiscovery, ServiceFilter serviceFilter) {
-            this.serviceName = serviceName;
-            this.serviceDiscovery = serviceDiscovery;
-            this.serviceFilter = serviceFilter;
-        }
-
-        @Override
-        public List<RibbonServiceDefinition> getInitialListOfServers() {
-            List<ServiceDefinition> services = serviceDiscovery.getServices(serviceName);
-            if (serviceFilter != null) {
-                services = serviceFilter.apply(services);
-            }
-
-            return asRibbonServerList(services);
-        }
-
-        @Override
-        public List<RibbonServiceDefinition> getUpdatedListOfServers() {
-            List<ServiceDefinition> services = serviceDiscovery.getServices(serviceName);
-            if (serviceFilter != null) {
-                services = serviceFilter.apply(services);
-            }
-
-            return asRibbonServerList(services);
-        }
-
-        private List<RibbonServiceDefinition> asRibbonServerList(List<ServiceDefinition> services) {
-            List<RibbonServiceDefinition> ribbonServers = new ArrayList<>();
-
-            for (ServiceDefinition service : services) {
-                if (service instanceof RibbonServiceDefinition) {
-                    ribbonServers.add((RibbonServiceDefinition)service);
-                } else {
-                    RibbonServiceDefinition serviceDef = new RibbonServiceDefinition(
-                        serviceName,
-                        service.getHost(),
-                        service.getPort(),
-                        service.getHealth()
-                    );
-
-                    String zone = serviceDef.getMetadata().get("zone");
-                    if (zone != null) {
-                        serviceDef.setZone(zone);
-                    }
-
-                    ribbonServers.add(serviceDef);
-                }
-            }
-
-            return ribbonServers;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/cloud/RibbonLoadBalancerFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/cloud/RibbonLoadBalancerFactory.java b/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/cloud/RibbonLoadBalancerFactory.java
deleted file mode 100644
index f166011..0000000
--- a/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/cloud/RibbonLoadBalancerFactory.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.ribbon.cloud;
-
-import java.util.Map;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.cloud.LoadBalancer;
-import org.apache.camel.cloud.LoadBalancerFactory;
-import org.apache.camel.component.ribbon.RibbonConfiguration;
-
-public class RibbonLoadBalancerFactory implements LoadBalancerFactory {
-    private final RibbonConfiguration configuration;
-
-    public RibbonLoadBalancerFactory() {
-        this(new RibbonConfiguration());
-    }
-
-    public RibbonLoadBalancerFactory(RibbonConfiguration configuration) {
-        this.configuration = configuration;
-    }
-
-    // *************************************************************************
-    // Properties
-    // *************************************************************************
-
-    public String getNamespace() {
-        return configuration.getNamespace();
-    }
-
-    public void setNamespace(String namespace) {
-        configuration.setNamespace(namespace);
-    }
-
-    public String getUsername() {
-        return configuration.getUsername();
-    }
-
-    public void setUsername(String username) {
-        configuration.setUsername(username);
-    }
-
-    public String getPassword() {
-        return configuration.getPassword();
-    }
-
-    public void setPassword(String password) {
-        configuration.setPassword(password);
-    }
-
-    public String getClientName() {
-        return configuration.getClientName();
-    }
-
-    public void setClientName(String clientName) {
-        configuration.setClientName(clientName);
-    }
-
-    public Map<String, String> getProperties() {
-        return configuration.getProperties();
-    }
-
-    public void setProperties(Map<String, String> clientConfig) {
-        configuration.setProperties(clientConfig);
-    }
-
-    // *************************************************************************
-    // Factory
-    // *************************************************************************
-
-    @Override
-    public LoadBalancer newInstance(CamelContext camelContext) throws Exception {
-        return new RibbonLoadBalancer(configuration);
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/cloud/RibbonServiceLoadBalancer.java
----------------------------------------------------------------------
diff --git a/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/cloud/RibbonServiceLoadBalancer.java b/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/cloud/RibbonServiceLoadBalancer.java
new file mode 100644
index 0000000..b5415c3
--- /dev/null
+++ b/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/cloud/RibbonServiceLoadBalancer.java
@@ -0,0 +1,259 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.ribbon.cloud;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.RejectedExecutionException;
+
+import com.netflix.client.config.IClientConfig;
+import com.netflix.client.config.IClientConfigKey;
+import com.netflix.loadbalancer.DummyPing;
+import com.netflix.loadbalancer.ILoadBalancer;
+import com.netflix.loadbalancer.PollingServerListUpdater;
+import com.netflix.loadbalancer.RoundRobinRule;
+import com.netflix.loadbalancer.Server;
+import com.netflix.loadbalancer.ServerList;
+import com.netflix.loadbalancer.ZoneAwareLoadBalancer;
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.cloud.ServiceDefinition;
+import org.apache.camel.cloud.ServiceDiscovery;
+import org.apache.camel.cloud.ServiceDiscoveryAware;
+import org.apache.camel.cloud.ServiceFilter;
+import org.apache.camel.cloud.ServiceFilterAware;
+import org.apache.camel.cloud.ServiceLoadBalancer;
+import org.apache.camel.cloud.ServiceLoadBalancerFunction;
+import org.apache.camel.component.ribbon.RibbonConfiguration;
+import org.apache.camel.support.ServiceSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.ServiceHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RibbonServiceLoadBalancer
+        extends ServiceSupport
+        implements CamelContextAware, ServiceDiscoveryAware, ServiceFilterAware, ServiceLoadBalancer {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(RibbonServiceLoadBalancer.class);
+
+    private final RibbonConfiguration configuration;
+    private final ConcurrentMap<String, ZoneAwareLoadBalancer<RibbonServiceDefinition>> loadBalancers;
+    private CamelContext camelContext;
+    private ServiceDiscovery serviceDiscovery;
+    private ServiceFilter serviceFilter;
+
+    public RibbonServiceLoadBalancer(RibbonConfiguration configuration) {
+        this.configuration = configuration;
+        this.loadBalancers = new ConcurrentHashMap<>();
+    }
+
+    @Override
+    public CamelContext getCamelContext() {
+        return camelContext;
+    }
+
+    @Override
+    public void setCamelContext(CamelContext camelContext) {
+        this.camelContext = camelContext;
+    }
+
+    @Override
+    public ServiceDiscovery getServiceDiscovery() {
+        return serviceDiscovery;
+    }
+
+    @Override
+    public void setServiceDiscovery(ServiceDiscovery serviceDiscovery) {
+        this.serviceDiscovery = serviceDiscovery;
+    }
+
+    @Override
+    public ServiceFilter getServiceFilter() {
+        return serviceFilter;
+    }
+
+    @Override
+    public void setServiceFilter(ServiceFilter serviceFilter) {
+        this.serviceFilter = serviceFilter;
+    }
+
+    // ************************
+    // lifecycle
+    // ************************
+
+    @Override
+    protected void doStart() throws Exception {
+        ObjectHelper.notNull(configuration, "configuration");
+        ObjectHelper.notNull(camelContext, "camel context");
+
+        if (serviceDiscovery != null) {
+            LOGGER.info("ServiceCall is using ribbon load balancer with service discovery type: {} and service filter: {}",
+                serviceDiscovery.getClass(),
+                serviceDiscovery != null ? serviceFilter.getClass() : "none");
+        } else {
+            LOGGER.info("ServiceCall is using ribbon load balancer");
+        }
+
+        ServiceHelper.startService(serviceDiscovery);
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        loadBalancers.values().forEach(ZoneAwareLoadBalancer::stopServerListRefreshing);
+        loadBalancers.clear();
+
+        ServiceHelper.stopService(serviceDiscovery);
+    }
+
+    // ************************
+    // Processor
+    // ************************
+
+    @Override
+    public <T> T process(String serviceName, ServiceLoadBalancerFunction<T> request) throws Exception {
+        ILoadBalancer loadBalancer = loadBalancers.computeIfAbsent(serviceName, key -> createLoadBalancer(key));
+        Server server = loadBalancer.chooseServer(serviceName);
+
+        if (server == null) {
+            throw new RejectedExecutionException("No active services with name " + serviceName);
+        }
+
+        ServiceDefinition definition;
+
+        if (server instanceof ServiceDefinition) {
+            // If the service discovery is one of camel provides, the definition
+            // is already of the expected type.
+            definition = (ServiceDefinition)server;
+        } else {
+            // If ribbon server list is configured through client config properties
+            // i.e. with listOfServers property the instance provided by the load
+            // balancer is of type Server so a conversion is needed
+            definition = new RibbonServiceDefinition(
+                serviceName,
+                server.getHost(),
+                server.getPort()
+            );
+
+            String zone = server.getZone();
+            if (zone != null) {
+                server.setZone(zone);
+            }
+        }
+
+        return request.apply(definition);
+    }
+
+    // ************************
+    // Helpers
+    // ************************
+
+    private ZoneAwareLoadBalancer<RibbonServiceDefinition> createLoadBalancer(String serviceName) {
+        // setup client config
+        IClientConfig config = configuration.getClientName() != null
+            ? IClientConfig.Builder.newBuilder(configuration.getClientName()).build()
+            : IClientConfig.Builder.newBuilder().build();
+
+        if (configuration.getProperties() != null) {
+            for (Map.Entry<String, String> entry : configuration.getProperties().entrySet()) {
+                IClientConfigKey key = IClientConfigKey.Keys.valueOf(entry.getKey());
+                String value = entry.getValue();
+
+                LOGGER.debug("RibbonClientConfig: {}={}", key.key(), value);
+                config.set(key, value);
+            }
+        }
+
+        ZoneAwareLoadBalancer<RibbonServiceDefinition> loadBalancer;
+
+        if (serviceDiscovery != null) {
+            loadBalancer = new ZoneAwareLoadBalancer<>(
+                config,
+                configuration.getRuleOrDefault(RoundRobinRule::new),
+                configuration.getPingOrDefault(DummyPing::new),
+                new RibbonServerList(serviceName, serviceDiscovery, serviceFilter),
+                null,
+                new PollingServerListUpdater(config));
+        } else {
+            loadBalancer = new ZoneAwareLoadBalancer<>(config);
+        }
+
+        return loadBalancer;
+    }
+
+    static final class RibbonServerList implements ServerList<RibbonServiceDefinition>  {
+        private final String serviceName;
+        private final ServiceDiscovery serviceDiscovery;
+        private final ServiceFilter serviceFilter;
+
+        RibbonServerList(String serviceName, ServiceDiscovery serviceDiscovery, ServiceFilter serviceFilter) {
+            this.serviceName = serviceName;
+            this.serviceDiscovery = serviceDiscovery;
+            this.serviceFilter = serviceFilter;
+        }
+
+        @Override
+        public List<RibbonServiceDefinition> getInitialListOfServers() {
+            List<ServiceDefinition> services = serviceDiscovery.getServices(serviceName);
+            if (serviceFilter != null) {
+                services = serviceFilter.apply(services);
+            }
+
+            return asRibbonServerList(services);
+        }
+
+        @Override
+        public List<RibbonServiceDefinition> getUpdatedListOfServers() {
+            List<ServiceDefinition> services = serviceDiscovery.getServices(serviceName);
+            if (serviceFilter != null) {
+                services = serviceFilter.apply(services);
+            }
+
+            return asRibbonServerList(services);
+        }
+
+        private List<RibbonServiceDefinition> asRibbonServerList(List<ServiceDefinition> services) {
+            List<RibbonServiceDefinition> ribbonServers = new ArrayList<>();
+
+            for (ServiceDefinition service : services) {
+                if (service instanceof RibbonServiceDefinition) {
+                    ribbonServers.add((RibbonServiceDefinition)service);
+                } else {
+                    RibbonServiceDefinition serviceDef = new RibbonServiceDefinition(
+                        serviceName,
+                        service.getHost(),
+                        service.getPort(),
+                        service.getHealth()
+                    );
+
+                    String zone = serviceDef.getMetadata().get("zone");
+                    if (zone != null) {
+                        serviceDef.setZone(zone);
+                    }
+
+                    ribbonServers.add(serviceDef);
+                }
+            }
+
+            return ribbonServers;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/cloud/RibbonServiceLoadBalancerFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/cloud/RibbonServiceLoadBalancerFactory.java b/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/cloud/RibbonServiceLoadBalancerFactory.java
new file mode 100644
index 0000000..0e328bf
--- /dev/null
+++ b/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/cloud/RibbonServiceLoadBalancerFactory.java
@@ -0,0 +1,89 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ribbon.cloud;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.cloud.ServiceLoadBalancer;
+import org.apache.camel.cloud.ServiceLoadBalancerFactory;
+import org.apache.camel.component.ribbon.RibbonConfiguration;
+
+public class RibbonServiceLoadBalancerFactory implements ServiceLoadBalancerFactory {
+    private final RibbonConfiguration configuration;
+
+    public RibbonServiceLoadBalancerFactory() {
+        this(new RibbonConfiguration());
+    }
+
+    public RibbonServiceLoadBalancerFactory(RibbonConfiguration configuration) {
+        this.configuration = configuration;
+    }
+
+    // *************************************************************************
+    // Properties
+    // *************************************************************************
+
+    public String getNamespace() {
+        return configuration.getNamespace();
+    }
+
+    public void setNamespace(String namespace) {
+        configuration.setNamespace(namespace);
+    }
+
+    public String getUsername() {
+        return configuration.getUsername();
+    }
+
+    public void setUsername(String username) {
+        configuration.setUsername(username);
+    }
+
+    public String getPassword() {
+        return configuration.getPassword();
+    }
+
+    public void setPassword(String password) {
+        configuration.setPassword(password);
+    }
+
+    public String getClientName() {
+        return configuration.getClientName();
+    }
+
+    public void setClientName(String clientName) {
+        configuration.setClientName(clientName);
+    }
+
+    public Map<String, String> getProperties() {
+        return configuration.getProperties();
+    }
+
+    public void setProperties(Map<String, String> clientConfig) {
+        configuration.setProperties(clientConfig);
+    }
+
+    // *************************************************************************
+    // Factory
+    // *************************************************************************
+
+    @Override
+    public ServiceLoadBalancer newInstance(CamelContext camelContext) throws Exception {
+        return new RibbonServiceLoadBalancer(configuration);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-ribbon/src/main/resources/META-INF/services/org/apache/camel/cloud/ribbon-load-balancer
----------------------------------------------------------------------
diff --git a/components/camel-ribbon/src/main/resources/META-INF/services/org/apache/camel/cloud/ribbon-load-balancer b/components/camel-ribbon/src/main/resources/META-INF/services/org/apache/camel/cloud/ribbon-load-balancer
deleted file mode 100644
index 161ac23..0000000
--- a/components/camel-ribbon/src/main/resources/META-INF/services/org/apache/camel/cloud/ribbon-load-balancer
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-class=org.apache.camel.component.ribbon.cloud.RibbonLoadBalancerFactory

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-ribbon/src/main/resources/META-INF/services/org/apache/camel/cloud/ribbon-service-load-balancer
----------------------------------------------------------------------
diff --git a/components/camel-ribbon/src/main/resources/META-INF/services/org/apache/camel/cloud/ribbon-service-load-balancer b/components/camel-ribbon/src/main/resources/META-INF/services/org/apache/camel/cloud/ribbon-service-load-balancer
new file mode 100644
index 0000000..65c38dd
--- /dev/null
+++ b/components/camel-ribbon/src/main/resources/META-INF/services/org/apache/camel/cloud/ribbon-service-load-balancer
@@ -0,0 +1,17 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+class=org.apache.camel.component.ribbon.cloud.RibbonServiceLoadBalancerFactory

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServerListTest.java
----------------------------------------------------------------------
diff --git a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServerListTest.java b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServerListTest.java
index f0d5dc3..a1f9c54 100644
--- a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServerListTest.java
+++ b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServerListTest.java
@@ -31,7 +31,7 @@ public class RibbonServerListTest {
     @Test
     public void testFixedServerList() throws Exception {
         ZoneAwareLoadBalancer<RibbonServiceDefinition> lb = LoadBalancerBuilder.<RibbonServiceDefinition>newBuilder()
-            .withDynamicServerList(new RibbonLoadBalancer.RibbonServerList(
+            .withDynamicServerList(new RibbonServiceLoadBalancer.RibbonServerList(
                 "unknown",
                 StaticServiceDiscovery.forServices(
                     new RibbonServiceDefinition("unknown", "localhost", 9090),

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServiceCallRegistryRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServiceCallRegistryRouteTest.java b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServiceCallRegistryRouteTest.java
index 7f95639..5be0344 100644
--- a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServiceCallRegistryRouteTest.java
+++ b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServiceCallRegistryRouteTest.java
@@ -35,7 +35,7 @@ public class RibbonServiceCallRegistryRouteTest extends RibbonServiceCallRouteTe
                 servers.addServer("localhost", 9091);
 
                 RibbonConfiguration configuration = new RibbonConfiguration();
-                RibbonLoadBalancer loadBalancer = new RibbonLoadBalancer(configuration);
+                RibbonServiceLoadBalancer loadBalancer = new RibbonServiceLoadBalancer(configuration);
 
                 // configure camel service call
                 ServiceCallConfigurationDefinition config = new ServiceCallConfigurationDefinition();

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServiceCallRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServiceCallRouteTest.java b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServiceCallRouteTest.java
index 6bda099..1b87c7a 100644
--- a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServiceCallRouteTest.java
+++ b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServiceCallRouteTest.java
@@ -50,7 +50,7 @@ public class RibbonServiceCallRouteTest extends CamelTestSupport {
                 servers.addServer("localhost", 9091);
 
                 RibbonConfiguration configuration = new RibbonConfiguration();
-                RibbonLoadBalancer loadBalancer = new RibbonLoadBalancer(configuration);
+                RibbonServiceLoadBalancer loadBalancer = new RibbonServiceLoadBalancer(configuration);
 
                 from("direct:start")
                     .serviceCall()

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServiceCallUpdateRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServiceCallUpdateRouteTest.java b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServiceCallUpdateRouteTest.java
index 27aba3e..38efa72 100644
--- a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServiceCallUpdateRouteTest.java
+++ b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServiceCallUpdateRouteTest.java
@@ -75,7 +75,7 @@ public class RibbonServiceCallUpdateRouteTest extends CamelTestSupport {
                 RibbonConfiguration configuration = new RibbonConfiguration();
                 // lets update quick so we do not have to sleep so much in the tests
                 configuration.addProperty("ServerListRefreshInterval", "250");
-                RibbonLoadBalancer loadBalancer = new RibbonLoadBalancer(configuration);
+                RibbonServiceLoadBalancer loadBalancer = new RibbonServiceLoadBalancer(configuration);
 
                 from("direct:start")
                     .serviceCall()

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringBeanServiceCallRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringBeanServiceCallRouteTest.java b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringBeanServiceCallRouteTest.java
index 9c99aec..5cbf8c4 100644
--- a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringBeanServiceCallRouteTest.java
+++ b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringBeanServiceCallRouteTest.java
@@ -17,6 +17,10 @@
 
 package org.apache.camel.component.ribbon.cloud;
 
+import org.apache.camel.impl.cloud.DefaultServiceCallProcessor;
+import org.apache.camel.impl.cloud.StaticServiceDiscovery;
+import org.junit.Assert;
+import org.junit.Test;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 import org.springframework.test.annotation.DirtiesContext;
@@ -27,5 +31,16 @@ public class SpringBeanServiceCallRouteTest extends SpringRibbonServiceCallRoute
     protected AbstractApplicationContext createApplicationContext() {
         return new ClassPathXmlApplicationContext("org/apache/camel/component/ribbon/cloud/SpringBeanRibbonServiceCallRouteTest.xml");
     }
+
+    @Test
+    public void testServiceCallConfiguration() throws Exception {
+        DefaultServiceCallProcessor processor = findServiceCallProcessor();
+
+        Assert.assertNotNull(processor.getLoadBalancer());
+        Assert.assertTrue(processor.getLoadBalancer() instanceof RibbonServiceLoadBalancer);
+
+        RibbonServiceLoadBalancer loadBalancer = (RibbonServiceLoadBalancer)processor.getLoadBalancer();
+        Assert.assertTrue(loadBalancer.getServiceDiscovery() instanceof StaticServiceDiscovery);
+    }
 }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringDslRibbonPropertiesServiceCallRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringDslRibbonPropertiesServiceCallRouteTest.java b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringDslRibbonPropertiesServiceCallRouteTest.java
index 9456b7a..56d734f 100644
--- a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringDslRibbonPropertiesServiceCallRouteTest.java
+++ b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringDslRibbonPropertiesServiceCallRouteTest.java
@@ -17,6 +17,9 @@
 
 package org.apache.camel.component.ribbon.cloud;
 
+import org.apache.camel.impl.cloud.DefaultServiceCallProcessor;
+import org.junit.Assert;
+import org.junit.Test;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 import org.springframework.test.annotation.DirtiesContext;
@@ -27,5 +30,16 @@ public class SpringDslRibbonPropertiesServiceCallRouteTest extends SpringRibbonS
     protected AbstractApplicationContext createApplicationContext() {
         return new ClassPathXmlApplicationContext("org/apache/camel/component/ribbon/cloud/SpringDslRibbonPropertiesServiceCallRouteTest.xml");
     }
+
+    @Test
+    public void testServiceCallConfiguration() throws Exception {
+        DefaultServiceCallProcessor processor = findServiceCallProcessor();
+
+        Assert.assertNotNull(processor.getLoadBalancer());
+        Assert.assertTrue(processor.getLoadBalancer() instanceof RibbonServiceLoadBalancer);
+
+        RibbonServiceLoadBalancer loadBalancer = (RibbonServiceLoadBalancer)processor.getLoadBalancer();
+        Assert.assertNull(loadBalancer.getServiceDiscovery());
+    }
 }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringDslRibbonServiceCallRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringDslRibbonServiceCallRouteTest.java b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringDslRibbonServiceCallRouteTest.java
index 34269b3..bb5304e 100644
--- a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringDslRibbonServiceCallRouteTest.java
+++ b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringDslRibbonServiceCallRouteTest.java
@@ -17,6 +17,10 @@
 
 package org.apache.camel.component.ribbon.cloud;
 
+import org.apache.camel.impl.cloud.DefaultServiceCallProcessor;
+import org.apache.camel.impl.cloud.StaticServiceDiscovery;
+import org.junit.Assert;
+import org.junit.Test;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 import org.springframework.test.annotation.DirtiesContext;
@@ -27,5 +31,16 @@ public class SpringDslRibbonServiceCallRouteTest extends SpringRibbonServiceCall
     protected AbstractApplicationContext createApplicationContext() {
         return new ClassPathXmlApplicationContext("org/apache/camel/component/ribbon/cloud/SpringDslRibbonServiceCallRouteTest.xml");
     }
+
+    @Test
+    public void testServiceCallConfiguration() throws Exception {
+        DefaultServiceCallProcessor processor = findServiceCallProcessor();
+
+        Assert.assertNotNull(processor.getLoadBalancer());
+        Assert.assertTrue(processor.getLoadBalancer() instanceof RibbonServiceLoadBalancer);
+
+        RibbonServiceLoadBalancer loadBalancer = (RibbonServiceLoadBalancer)processor.getLoadBalancer();
+        Assert.assertTrue(loadBalancer.getServiceDiscovery() instanceof StaticServiceDiscovery);
+    }
 }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringRibbonServiceCallRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringRibbonServiceCallRouteTest.java b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringRibbonServiceCallRouteTest.java
index 3c9e8b2..0ca03f8 100644
--- a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringRibbonServiceCallRouteTest.java
+++ b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringRibbonServiceCallRouteTest.java
@@ -17,7 +17,14 @@
 
 package org.apache.camel.component.ribbon.cloud;
 
+import java.util.Optional;
+
+import org.apache.camel.Navigate;
+import org.apache.camel.Processor;
+import org.apache.camel.Route;
+import org.apache.camel.impl.cloud.DefaultServiceCallProcessor;
 import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.junit.Assert;
 import org.junit.Test;
 import org.springframework.test.annotation.DirtiesContext;
 
@@ -36,5 +43,32 @@ public abstract class SpringRibbonServiceCallRouteTest extends CamelSpringTestSu
 
         assertMockEndpointsSatisfied();
     }
+
+    // ************************************
+    // Helpers
+    // ************************************
+
+    protected DefaultServiceCallProcessor findServiceCallProcessor() {
+        Route route = context().getRoute("scall");
+
+        Assert.assertNotNull("ServiceCall Route should be present", route);
+
+        return findServiceCallProcessor(route.navigate())
+            .orElseThrow(() -> new IllegalStateException("Unable to find a ServiceCallProcessor"));
+    }
+
+    protected Optional<DefaultServiceCallProcessor> findServiceCallProcessor(Navigate<Processor> navigate) {
+        for (Processor processor : navigate.next()) {
+            if (processor instanceof DefaultServiceCallProcessor) {
+                return Optional.ofNullable((DefaultServiceCallProcessor)processor);
+            }
+
+            if (processor instanceof Navigate) {
+                return findServiceCallProcessor((Navigate<Processor>)processor);
+            }
+        }
+
+        return Optional.empty();
+    }
 }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringBeanRibbonServiceCallRouteTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringBeanRibbonServiceCallRouteTest.xml b/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringBeanRibbonServiceCallRouteTest.xml
index 01e59d9..22ad55c 100644
--- a/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringBeanRibbonServiceCallRouteTest.xml
+++ b/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringBeanRibbonServiceCallRouteTest.xml
@@ -28,7 +28,7 @@
     <property name="servers" value="localhost:9090,localhost:9091"/>
   </bean>
 
-  <bean id="balancer" class="org.apache.camel.component.ribbon.cloud.RibbonLoadBalancer">
+  <bean id="balancer" class="org.apache.camel.component.ribbon.cloud.RibbonServiceLoadBalancer">
     <constructor-arg index="0">
       <bean class="org.apache.camel.component.ribbon.RibbonConfiguration"/>
     </constructor-arg>
@@ -39,7 +39,7 @@
     <!-- service call configuration to use ribbon -->
     <serviceCallConfiguration id="ribbon" loadBalancerRef="balancer" serviceDiscoveryRef="discovery"/>
 
-    <route>
+    <route id="scall">
       <from uri="direct:start"/>
       <serviceCall name="myService"/>
       <to uri="mock:result"/>

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringDslRibbonPropertiesServiceCallRouteTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringDslRibbonPropertiesServiceCallRouteTest.xml b/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringDslRibbonPropertiesServiceCallRouteTest.xml
index b182bc2..3c92e91 100644
--- a/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringDslRibbonPropertiesServiceCallRouteTest.xml
+++ b/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringDslRibbonPropertiesServiceCallRouteTest.xml
@@ -24,7 +24,7 @@
          http://camel.apache.org/schema/spring/camel-spring.xsd">
 
   <camelContext xmlns="http://camel.apache.org/schema/spring">
-    <route>
+    <route id="scall">
       <from uri="direct:start"/>
       <serviceCall name="myService">
         <!-- enable ribbon load balancer -->

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringDslRibbonServiceCallRouteTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringDslRibbonServiceCallRouteTest.xml b/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringDslRibbonServiceCallRouteTest.xml
index 48ce72a..8a40924 100644
--- a/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringDslRibbonServiceCallRouteTest.xml
+++ b/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringDslRibbonServiceCallRouteTest.xml
@@ -24,7 +24,7 @@
          http://camel.apache.org/schema/spring/camel-spring.xsd">
 
   <camelContext xmlns="http://camel.apache.org/schema/spring">
-    <route>
+    <route id="scall">
       <from uri="direct:start"/>
       <serviceCall name="myService">
         <!-- static list of servers -->

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cloud/CamelCloudConfigurationProperties.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cloud/CamelCloudConfigurationProperties.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cloud/CamelCloudConfigurationProperties.java
index 937e042..31ebf09 100644
--- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cloud/CamelCloudConfigurationProperties.java
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cloud/CamelCloudConfigurationProperties.java
@@ -21,6 +21,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.camel.Expression;
+import org.apache.camel.cloud.ServiceLoadBalancer;
 import org.apache.camel.model.cloud.ServiceCallConstants;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 
@@ -93,7 +94,7 @@ public class CamelCloudConfigurationProperties {
         private String serviceChooser;
 
         /**
-         * A reference to the {@link org.apache.camel.cloud.LoadBalancer} to use.
+         * A reference to the {@link ServiceLoadBalancer} to use.
          */
         private String loadBalancer;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallConfigurationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallConfigurationTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallConfigurationTest.java
index 282af31..3f3415a 100644
--- a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallConfigurationTest.java
+++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallConfigurationTest.java
@@ -17,7 +17,7 @@
 
 package org.apache.camel.spring.boot.cloud;
 
-import org.apache.camel.cloud.LoadBalancer;
+import org.apache.camel.cloud.ServiceLoadBalancer;
 import org.apache.camel.cloud.ServiceChooser;
 import org.apache.camel.cloud.ServiceDiscovery;
 import org.apache.camel.cloud.ServiceFilter;
@@ -70,7 +70,7 @@ public class CamelCloudServiceCallConfigurationTest {
         assertTrue(ctx.getBeansOfType(ServiceDiscovery.class).isEmpty());
         assertTrue(ctx.getBeansOfType(ServiceFilter.class).isEmpty());
         assertTrue(ctx.getBeansOfType(ServiceChooser.class).isEmpty());
-        assertTrue(ctx.getBeansOfType(LoadBalancer.class).isEmpty());
+        assertTrue(ctx.getBeansOfType(ServiceLoadBalancer.class).isEmpty());
     }
 }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudLoadBalancer.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudLoadBalancer.java b/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudLoadBalancer.java
deleted file mode 100644
index bfd6ab8..0000000
--- a/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudLoadBalancer.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.spring.cloud;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.CamelContextAware;
-import org.apache.camel.cloud.LoadBalancer;
-import org.apache.camel.cloud.LoadBalancerFunction;
-import org.apache.camel.cloud.ServiceDefinition;
-import org.apache.camel.impl.cloud.DefaultServiceDefinition;
-import org.apache.camel.support.ServiceSupport;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.cloud.client.ServiceInstance;
-import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
-
-public class CamelSpringCloudLoadBalancer extends ServiceSupport implements CamelContextAware, LoadBalancer {
-    private static final Logger LOGGER = LoggerFactory.getLogger(CamelSpringCloudLoadBalancer.class);
-
-    private final LoadBalancerClient loadBalancerClient;
-    private CamelContext camelContext;
-
-    public CamelSpringCloudLoadBalancer(LoadBalancerClient loadBalancerClient) {
-        this.loadBalancerClient = loadBalancerClient;
-    }
-
-    @Override
-    public CamelContext getCamelContext() {
-        return camelContext;
-    }
-
-    @Override
-    public void setCamelContext(CamelContext camelContext) {
-        this.camelContext = camelContext;
-    }
-
-    @Override
-    protected void doStart() throws Exception {
-        ObjectHelper.notNull(camelContext, "camelContext");
-        ObjectHelper.notNull(loadBalancerClient, "loadBalancerClient");
-
-        LOGGER.info("ServiceCall is using cloud load balancer of type: {}", loadBalancerClient.getClass());
-    }
-
-    @Override
-    protected void doStop() throws Exception {
-    }
-
-    @Override
-    public <T> T process(String serviceName, LoadBalancerFunction<T> function) throws Exception {
-        return loadBalancerClient.execute(serviceName,  i -> function.apply(instanceToDefinition(i)));
-    }
-
-    // *******************************
-    // Helpers
-    // *******************************
-
-    private ServiceDefinition instanceToDefinition(ServiceInstance instance) {
-        return new DefaultServiceDefinition(
-            instance.getServiceId(),
-            instance.getHost(),
-            instance.getPort(),
-            instance.getMetadata()
-        );
-    }
-}
\ No newline at end of file


[3/4] camel git commit: Rename LoadBalancer to ServiceLoadBalancer to avoid confusion with LoadBalancer processor

Posted by lb...@apache.org.
Rename LoadBalancer to ServiceLoadBalancer to avoid confusion with LoadBalancer processor


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

Branch: refs/heads/master
Commit: ecc81927b0b55be81fe7d3e1b80d84d922029d25
Parents: 56f2b24
Author: lburgazzoli <lb...@gmail.com>
Authored: Wed Apr 19 13:36:19 2017 +0200
Committer: lburgazzoli <lb...@gmail.com>
Committed: Wed Apr 19 17:25:31 2017 +0200

----------------------------------------------------------------------
 .../org/apache/camel/cloud/LoadBalancer.java    |  29 ---
 .../apache/camel/cloud/LoadBalancerFactory.java |  32 ---
 .../camel/cloud/LoadBalancerFunction.java       |  25 --
 .../camel/cloud/ServiceChooserFactory.java      |  11 +-
 .../camel/cloud/ServiceDiscoveryFactory.java    |  11 +-
 .../camel/cloud/ServiceExpressionFactory.java   |  10 +-
 .../org/apache/camel/cloud/ServiceFactory.java  |  27 ++
 .../camel/cloud/ServiceFilterFactory.java       |  11 +-
 .../apache/camel/cloud/ServiceLoadBalancer.java |  29 +++
 .../camel/cloud/ServiceLoadBalancerFactory.java |  27 ++
 .../cloud/ServiceLoadBalancerFunction.java      |  25 ++
 .../camel/impl/cloud/DefaultLoadBalancer.java   | 147 -----------
 .../impl/cloud/DefaultLoadBalancerFactory.java  |  32 ---
 .../impl/cloud/DefaultServiceCallProcessor.java |   8 +-
 .../impl/cloud/DefaultServiceLoadBalancer.java  | 147 +++++++++++
 .../DefaultServiceLoadBalancerFactory.java      |  32 +++
 ...ultServiceCallLoadBalancerConfiguration.java |  47 ----
 ...iceCallServiceLoadBalancerConfiguration.java |  37 +++
 ...bonServiceCallLoadBalancerConfiguration.java | 144 -----------
 ...iceCallServiceLoadBalancerConfiguration.java | 130 ++++++++++
 .../ServiceCallConfigurationDefinition.java     |  36 +--
 .../model/cloud/ServiceCallDefinition.java      |  56 ++--
 .../ServiceCallExpressionConfiguration.java     |   2 +
 .../ServiceCallLoadBalancerConfiguration.java   | 187 -------------
 .../ServiceCallServiceChooserConfiguration.java |   4 +
 ...erviceCallServiceDiscoveryConfiguration.java |   2 +
 .../ServiceCallServiceFilterConfiguration.java  |   2 +
 ...iceCallServiceLoadBalancerConfiguration.java | 189 ++++++++++++++
 .../apache/camel/cloud/default-load-balancer    |  17 --
 .../camel/cloud/default-service-load-balancer   |  17 ++
 .../org/apache/camel/model/cloud/jaxb.index     |   5 +-
 .../camel/impl/cloud/LoadBalancerTest.java      |   2 +-
 .../cloud/ServiceCallConfigurationTest.java     |  26 +-
 ...SpringConsulDefaultServiceCallRouteTest.java |  16 ++
 ...ingConsulExpressionServiceCallRouteTest.java |  16 ++
 .../SpringConsulRibbonServiceCallRouteTest.java |  16 ++
 .../cloud/SpringConsulServiceCallRouteTest.java |  37 +++
 .../SpringConsulDefaultServiceCallRouteTest.xml |   2 +-
 ...ringConsulExpressionServiceCallRouteTest.xml |   2 +-
 .../SpringConsulRibbonServiceCallRouteTest.xml  |   2 +-
 .../camel/component/etcd/EtcdConfiguration.java |   6 +-
 .../ribbon/cloud/RibbonLoadBalancer.java        | 259 -------------------
 .../ribbon/cloud/RibbonLoadBalancerFactory.java |  89 -------
 .../ribbon/cloud/RibbonServiceLoadBalancer.java | 259 +++++++++++++++++++
 .../cloud/RibbonServiceLoadBalancerFactory.java |  89 +++++++
 .../org/apache/camel/cloud/ribbon-load-balancer |  17 --
 .../camel/cloud/ribbon-service-load-balancer    |  17 ++
 .../ribbon/cloud/RibbonServerListTest.java      |   2 +-
 .../RibbonServiceCallRegistryRouteTest.java     |   2 +-
 .../cloud/RibbonServiceCallRouteTest.java       |   2 +-
 .../cloud/RibbonServiceCallUpdateRouteTest.java |   2 +-
 .../cloud/SpringBeanServiceCallRouteTest.java   |  15 ++
 ...DslRibbonPropertiesServiceCallRouteTest.java |  14 +
 .../SpringDslRibbonServiceCallRouteTest.java    |  15 ++
 .../cloud/SpringRibbonServiceCallRouteTest.java |  34 +++
 .../SpringBeanRibbonServiceCallRouteTest.xml    |   4 +-
 ...gDslRibbonPropertiesServiceCallRouteTest.xml |   2 +-
 .../SpringDslRibbonServiceCallRouteTest.xml     |   2 +-
 .../CamelCloudConfigurationProperties.java      |   3 +-
 .../CamelCloudServiceCallConfigurationTest.java |   4 +-
 .../cloud/CamelSpringCloudLoadBalancer.java     |  81 ------
 ...pringCloudLoadBalancerAutoConfiguration.java |  59 -----
 .../CamelSpringCloudServiceLoadBalancer.java    |  81 ++++++
 ...oudServiceLoadBalancerAutoConfiguration.java |  59 +++++
 .../main/resources/META-INF/spring.factories    |   2 +-
 .../cloud/ServiceCallConfigurationTest.java     |   4 +-
 ...viceCallLoadBalancerConfigurationCommon.java |  91 -------
 ...CallLoadBalancerConfigurationProperties.java |  50 ----
 ...lServiceLoadBalancerConfigurationCommon.java |  91 +++++++
 ...viceLoadBalancerConfigurationProperties.java |  50 ++++
 .../camel-ribbon-starter/pom.xml                |   5 +
 .../cloud/RibbonCloudAutoConfiguration.java     |  20 +-
 .../cloud/RibbonLoadBalancerDisabledTest.java   |   8 +-
 .../cloud/RibbonLoadBalancerEnabledTest.java    |   8 +-
 .../cloud/RibbonLoadBalancerTest.java           | 124 +++++++++
 75 files changed, 1726 insertions(+), 1441 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/cloud/LoadBalancer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/cloud/LoadBalancer.java b/camel-core/src/main/java/org/apache/camel/cloud/LoadBalancer.java
deleted file mode 100644
index 5974baf..0000000
--- a/camel-core/src/main/java/org/apache/camel/cloud/LoadBalancer.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cloud;
-
-/**
- * Represents a Load Balancer.
- *
- * @see ServiceDiscovery
- * @see ServiceFilter
- * @see ServiceChooser
- */
-@FunctionalInterface
-public interface LoadBalancer {
-    <T> T process(String serviceName, LoadBalancerFunction<T> function) throws Exception;
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/cloud/LoadBalancerFactory.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/cloud/LoadBalancerFactory.java b/camel-core/src/main/java/org/apache/camel/cloud/LoadBalancerFactory.java
deleted file mode 100644
index 83ba0e5..0000000
--- a/camel-core/src/main/java/org/apache/camel/cloud/LoadBalancerFactory.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cloud;
-
-import org.apache.camel.CamelContext;
-
-/**
- * A factory to create LoadBalancer
- *
- * @see LoadBalancer
- */
-public interface LoadBalancerFactory {
-
-    /**
-     * Creates an instance of a LoadBalancer.
-     */
-    LoadBalancer newInstance(CamelContext camelContext) throws Exception;
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/cloud/LoadBalancerFunction.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/cloud/LoadBalancerFunction.java b/camel-core/src/main/java/org/apache/camel/cloud/LoadBalancerFunction.java
deleted file mode 100644
index b1a96d6..0000000
--- a/camel-core/src/main/java/org/apache/camel/cloud/LoadBalancerFunction.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cloud;
-
-/**
- * Represents a load balancer function to be executed by the LoadBalancer.
- */
-@FunctionalInterface
-public interface LoadBalancerFunction<T> {
-    T apply(ServiceDefinition serviceDefinition) throws Exception;
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/cloud/ServiceChooserFactory.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/cloud/ServiceChooserFactory.java b/camel-core/src/main/java/org/apache/camel/cloud/ServiceChooserFactory.java
index b3fead9..a80cc34 100644
--- a/camel-core/src/main/java/org/apache/camel/cloud/ServiceChooserFactory.java
+++ b/camel-core/src/main/java/org/apache/camel/cloud/ServiceChooserFactory.java
@@ -16,17 +16,12 @@
  */
 package org.apache.camel.cloud;
 
-import org.apache.camel.CamelContext;
-
 /**
  * A factory to create ServiceChooser
  *
+ * @see ServiceFactory
  * @see ServiceChooser
  */
-public interface ServiceChooserFactory {
-
-    /**
-     * Creates an instance of a ServiceChooser.
-     */
-    ServiceChooser newInstance(CamelContext camelContext) throws Exception;
+@FunctionalInterface
+public interface ServiceChooserFactory extends ServiceFactory<ServiceChooser> {
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/cloud/ServiceDiscoveryFactory.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/cloud/ServiceDiscoveryFactory.java b/camel-core/src/main/java/org/apache/camel/cloud/ServiceDiscoveryFactory.java
index b9498d3..c252a06 100644
--- a/camel-core/src/main/java/org/apache/camel/cloud/ServiceDiscoveryFactory.java
+++ b/camel-core/src/main/java/org/apache/camel/cloud/ServiceDiscoveryFactory.java
@@ -16,17 +16,12 @@
  */
 package org.apache.camel.cloud;
 
-import org.apache.camel.CamelContext;
-
 /**
  * A factory to create ServiceDiscovery
  *
+ * @see ServiceFactory
  * @see ServiceDiscovery
  */
-public interface ServiceDiscoveryFactory {
-
-    /**
-     * Creates an instance of a ServiceDiscovery.
-     */
-    ServiceDiscovery newInstance(CamelContext camelContext) throws Exception;
+@FunctionalInterface
+public interface ServiceDiscoveryFactory extends ServiceFactory<ServiceDiscovery> {
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/cloud/ServiceExpressionFactory.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/cloud/ServiceExpressionFactory.java b/camel-core/src/main/java/org/apache/camel/cloud/ServiceExpressionFactory.java
index 3bdb2d7..4f4dcf2 100644
--- a/camel-core/src/main/java/org/apache/camel/cloud/ServiceExpressionFactory.java
+++ b/camel-core/src/main/java/org/apache/camel/cloud/ServiceExpressionFactory.java
@@ -16,18 +16,14 @@
  */
 package org.apache.camel.cloud;
 
-import org.apache.camel.CamelContext;
 import org.apache.camel.Expression;
 
 /**
  * A factory to create Expression
  *
+ * @see ServiceFactory
  * @see Expression
  */
-public interface ServiceExpressionFactory {
-
-    /**
-     * Creates an instance of a ServiceChooser.
-     */
-    Expression newInstance(CamelContext camelContext) throws Exception;
+@FunctionalInterface
+public interface ServiceExpressionFactory extends ServiceFactory<Expression> {
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/cloud/ServiceFactory.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/cloud/ServiceFactory.java b/camel-core/src/main/java/org/apache/camel/cloud/ServiceFactory.java
new file mode 100644
index 0000000..fd58661
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/cloud/ServiceFactory.java
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cloud;
+
+import org.apache.camel.CamelContext;
+
+@FunctionalInterface
+public interface ServiceFactory<T> {
+    /**
+     * Creates an instance of a service.
+     */
+    T newInstance(CamelContext camelContext) throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/cloud/ServiceFilterFactory.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/cloud/ServiceFilterFactory.java b/camel-core/src/main/java/org/apache/camel/cloud/ServiceFilterFactory.java
index e7845ab..8771671 100644
--- a/camel-core/src/main/java/org/apache/camel/cloud/ServiceFilterFactory.java
+++ b/camel-core/src/main/java/org/apache/camel/cloud/ServiceFilterFactory.java
@@ -16,17 +16,12 @@
  */
 package org.apache.camel.cloud;
 
-import org.apache.camel.CamelContext;
-
 /**
  * A factory to create ServiceFilter
  *
+ * @see ServiceFactory
  * @see ServiceFilter
  */
-public interface ServiceFilterFactory {
-
-    /**
-     * Creates an instance of a ServiceFilter.
-     */
-    ServiceFilter newInstance(CamelContext camelContext) throws Exception;
+@FunctionalInterface
+public interface ServiceFilterFactory extends ServiceFactory<ServiceFilter> {
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/cloud/ServiceLoadBalancer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/cloud/ServiceLoadBalancer.java b/camel-core/src/main/java/org/apache/camel/cloud/ServiceLoadBalancer.java
new file mode 100644
index 0000000..2fe32a1
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/cloud/ServiceLoadBalancer.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cloud;
+
+/**
+ * Represents a Load Balancer.
+ *
+ * @see ServiceDiscovery
+ * @see ServiceFilter
+ * @see ServiceChooser
+ */
+@FunctionalInterface
+public interface ServiceLoadBalancer {
+    <T> T process(String serviceName, ServiceLoadBalancerFunction<T> function) throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/cloud/ServiceLoadBalancerFactory.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/cloud/ServiceLoadBalancerFactory.java b/camel-core/src/main/java/org/apache/camel/cloud/ServiceLoadBalancerFactory.java
new file mode 100644
index 0000000..4fffaea
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/cloud/ServiceLoadBalancerFactory.java
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cloud;
+
+/**
+ * A factory to create LoadBalancer
+ *
+ * @see ServiceFactory
+ * @see ServiceLoadBalancer
+ */
+@FunctionalInterface
+public interface ServiceLoadBalancerFactory extends ServiceFactory<ServiceLoadBalancer> {
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/cloud/ServiceLoadBalancerFunction.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/cloud/ServiceLoadBalancerFunction.java b/camel-core/src/main/java/org/apache/camel/cloud/ServiceLoadBalancerFunction.java
new file mode 100644
index 0000000..b861e65
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/cloud/ServiceLoadBalancerFunction.java
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cloud;
+
+/**
+ * Represents a load balancer function to be executed by the LoadBalancer.
+ */
+@FunctionalInterface
+public interface ServiceLoadBalancerFunction<T> {
+    T apply(ServiceDefinition serviceDefinition) throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultLoadBalancer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultLoadBalancer.java b/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultLoadBalancer.java
deleted file mode 100644
index 9fc8051..0000000
--- a/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultLoadBalancer.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.impl.cloud;
-
-import java.util.List;
-import java.util.concurrent.RejectedExecutionException;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.CamelContextAware;
-import org.apache.camel.cloud.LoadBalancer;
-import org.apache.camel.cloud.LoadBalancerFunction;
-import org.apache.camel.cloud.ServiceChooser;
-import org.apache.camel.cloud.ServiceChooserAware;
-import org.apache.camel.cloud.ServiceDefinition;
-import org.apache.camel.cloud.ServiceDiscovery;
-import org.apache.camel.cloud.ServiceDiscoveryAware;
-import org.apache.camel.cloud.ServiceFilter;
-import org.apache.camel.cloud.ServiceFilterAware;
-import org.apache.camel.support.ServiceSupport;
-import org.apache.camel.util.ObjectHelper;
-import org.apache.camel.util.ServiceHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DefaultLoadBalancer
-        extends ServiceSupport
-        implements CamelContextAware, ServiceDiscoveryAware, ServiceChooserAware, ServiceFilterAware, LoadBalancer {
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(DefaultLoadBalancer.class);
-
-    private CamelContext camelContext;
-    private ServiceDiscovery serviceDiscovery;
-    private ServiceChooser serviceChooser;
-    private ServiceFilter serviceFilter;
-
-    public DefaultLoadBalancer() {
-    }
-
-    // *************************************
-    // Bean
-    // *************************************
-
-    @Override
-    public CamelContext getCamelContext() {
-        return camelContext;
-    }
-
-    @Override
-    public void setCamelContext(CamelContext camelContext) {
-        this.camelContext = camelContext;
-    }
-
-    @Override
-    public ServiceDiscovery getServiceDiscovery() {
-        return serviceDiscovery;
-    }
-
-    @Override
-    public void setServiceDiscovery(ServiceDiscovery serverDiscovery) {
-        this.serviceDiscovery = serverDiscovery;
-    }
-
-    @Override
-    public ServiceChooser getServiceChooser() {
-        return serviceChooser;
-    }
-
-    @Override
-    public void setServiceChooser(ServiceChooser serverChooser) {
-        this.serviceChooser = serverChooser;
-    }
-
-    @Override
-    public void setServiceFilter(ServiceFilter serviceFilter) {
-        this.serviceFilter = serviceFilter;
-    }
-
-    @Override
-    public ServiceFilter getServiceFilter() {
-        return serviceFilter;
-    }
-
-    // *************************************
-    // Lifecycle
-    // *************************************
-
-    @Override
-    protected void doStart() throws Exception {
-        ObjectHelper.notNull(camelContext, "camel context");
-        ObjectHelper.notNull(serviceDiscovery, "service discovery");
-        ObjectHelper.notNull(serviceChooser, "service chooser");
-        ObjectHelper.notNull(serviceFilter, "service serviceFilter");
-
-        LOGGER.info("ServiceCall is using default load balancer with service discovery type: {}, service filter type: {} and service chooser type: {}",
-            serviceDiscovery.getClass(),
-            serviceFilter.getClass(),
-            serviceChooser.getClass());
-
-        ServiceHelper.startService(serviceChooser);
-        ServiceHelper.startService(serviceDiscovery);
-    }
-
-    @Override
-    protected void doStop() throws Exception {
-        // Stop services if needed
-        ServiceHelper.stopService(serviceDiscovery);
-        ServiceHelper.stopService(serviceChooser);
-    }
-
-    // *************************************
-    // Load Balancer
-    // *************************************
-
-    @Override
-    public <T> T process(String serviceName, LoadBalancerFunction<T> function) throws Exception {
-        ServiceDefinition service;
-
-        List<ServiceDefinition> services = serviceDiscovery.getServices(serviceName);
-        if (services == null || services.isEmpty()) {
-            throw new RejectedExecutionException("No active services with name " + serviceName);
-        } else {
-            // filter services
-            services = serviceFilter.apply(services);
-            // let the client service chooser find which server to use
-            service = services.size() > 1 ? serviceChooser.choose(services) : services.get(0);
-            if (service == null) {
-                throw new RejectedExecutionException("No active services with name " + serviceName);
-            }
-        }
-
-        return function.apply(service);
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultLoadBalancerFactory.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultLoadBalancerFactory.java b/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultLoadBalancerFactory.java
deleted file mode 100644
index f065106..0000000
--- a/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultLoadBalancerFactory.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.impl.cloud;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.cloud.LoadBalancer;
-import org.apache.camel.cloud.LoadBalancerFactory;
-
-public class DefaultLoadBalancerFactory implements LoadBalancerFactory {
-
-    @Override
-    public LoadBalancer newInstance(CamelContext camelContext) throws Exception {
-        DefaultLoadBalancer loadBalancer = new DefaultLoadBalancer();
-        loadBalancer.setCamelContext(camelContext);
-
-        return loadBalancer;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultServiceCallProcessor.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultServiceCallProcessor.java b/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultServiceCallProcessor.java
index be97182..76094c1 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultServiceCallProcessor.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultServiceCallProcessor.java
@@ -23,8 +23,8 @@ import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.Expression;
 import org.apache.camel.Message;
-import org.apache.camel.cloud.LoadBalancer;
 import org.apache.camel.cloud.ServiceDefinition;
+import org.apache.camel.cloud.ServiceLoadBalancer;
 import org.apache.camel.processor.SendDynamicProcessor;
 import org.apache.camel.support.ServiceSupport;
 import org.apache.camel.util.AsyncProcessorHelper;
@@ -43,13 +43,13 @@ public class DefaultServiceCallProcessor extends ServiceSupport implements Async
     private final String uri;
     private final String contextPath;
     private final CamelContext camelContext;
-    private final LoadBalancer loadBalancer;
+    private final ServiceLoadBalancer loadBalancer;
     private final Expression expression;
     private SendDynamicProcessor processor;
 
     public DefaultServiceCallProcessor(
         CamelContext camelContext, String name, String scheme, String uri, ExchangePattern exchangePattern,
-        LoadBalancer loadBalancer, Expression expression) {
+        ServiceLoadBalancer loadBalancer, Expression expression) {
 
         this.uri = uri;
         this.exchangePattern = exchangePattern;
@@ -104,7 +104,7 @@ public class DefaultServiceCallProcessor extends ServiceSupport implements Async
         return contextPath;
     }
 
-    public LoadBalancer getLoadBalancer() {
+    public ServiceLoadBalancer getLoadBalancer() {
         return loadBalancer;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultServiceLoadBalancer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultServiceLoadBalancer.java b/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultServiceLoadBalancer.java
new file mode 100644
index 0000000..19a55fa
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultServiceLoadBalancer.java
@@ -0,0 +1,147 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.impl.cloud;
+
+import java.util.List;
+import java.util.concurrent.RejectedExecutionException;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.cloud.ServiceChooser;
+import org.apache.camel.cloud.ServiceChooserAware;
+import org.apache.camel.cloud.ServiceDefinition;
+import org.apache.camel.cloud.ServiceDiscovery;
+import org.apache.camel.cloud.ServiceDiscoveryAware;
+import org.apache.camel.cloud.ServiceFilter;
+import org.apache.camel.cloud.ServiceFilterAware;
+import org.apache.camel.cloud.ServiceLoadBalancer;
+import org.apache.camel.cloud.ServiceLoadBalancerFunction;
+import org.apache.camel.support.ServiceSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.ServiceHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DefaultServiceLoadBalancer
+        extends ServiceSupport
+        implements CamelContextAware, ServiceDiscoveryAware, ServiceChooserAware, ServiceFilterAware, ServiceLoadBalancer {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(DefaultServiceLoadBalancer.class);
+
+    private CamelContext camelContext;
+    private ServiceDiscovery serviceDiscovery;
+    private ServiceChooser serviceChooser;
+    private ServiceFilter serviceFilter;
+
+    public DefaultServiceLoadBalancer() {
+    }
+
+    // *************************************
+    // Bean
+    // *************************************
+
+    @Override
+    public CamelContext getCamelContext() {
+        return camelContext;
+    }
+
+    @Override
+    public void setCamelContext(CamelContext camelContext) {
+        this.camelContext = camelContext;
+    }
+
+    @Override
+    public ServiceDiscovery getServiceDiscovery() {
+        return serviceDiscovery;
+    }
+
+    @Override
+    public void setServiceDiscovery(ServiceDiscovery serverDiscovery) {
+        this.serviceDiscovery = serverDiscovery;
+    }
+
+    @Override
+    public ServiceChooser getServiceChooser() {
+        return serviceChooser;
+    }
+
+    @Override
+    public void setServiceChooser(ServiceChooser serverChooser) {
+        this.serviceChooser = serverChooser;
+    }
+
+    @Override
+    public void setServiceFilter(ServiceFilter serviceFilter) {
+        this.serviceFilter = serviceFilter;
+    }
+
+    @Override
+    public ServiceFilter getServiceFilter() {
+        return serviceFilter;
+    }
+
+    // *************************************
+    // Lifecycle
+    // *************************************
+
+    @Override
+    protected void doStart() throws Exception {
+        ObjectHelper.notNull(camelContext, "camel context");
+        ObjectHelper.notNull(serviceDiscovery, "service discovery");
+        ObjectHelper.notNull(serviceChooser, "service chooser");
+        ObjectHelper.notNull(serviceFilter, "service serviceFilter");
+
+        LOGGER.info("ServiceCall is using default load balancer with service discovery type: {}, service filter type: {} and service chooser type: {}",
+            serviceDiscovery.getClass(),
+            serviceFilter.getClass(),
+            serviceChooser.getClass());
+
+        ServiceHelper.startService(serviceChooser);
+        ServiceHelper.startService(serviceDiscovery);
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        // Stop services if needed
+        ServiceHelper.stopService(serviceDiscovery);
+        ServiceHelper.stopService(serviceChooser);
+    }
+
+    // *************************************
+    // Load Balancer
+    // *************************************
+
+    @Override
+    public <T> T process(String serviceName, ServiceLoadBalancerFunction<T> function) throws Exception {
+        ServiceDefinition service;
+
+        List<ServiceDefinition> services = serviceDiscovery.getServices(serviceName);
+        if (services == null || services.isEmpty()) {
+            throw new RejectedExecutionException("No active services with name " + serviceName);
+        } else {
+            // filter services
+            services = serviceFilter.apply(services);
+            // let the client service chooser find which server to use
+            service = services.size() > 1 ? serviceChooser.choose(services) : services.get(0);
+            if (service == null) {
+                throw new RejectedExecutionException("No active services with name " + serviceName);
+            }
+        }
+
+        return function.apply(service);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultServiceLoadBalancerFactory.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultServiceLoadBalancerFactory.java b/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultServiceLoadBalancerFactory.java
new file mode 100644
index 0000000..bdbb7f6
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultServiceLoadBalancerFactory.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.impl.cloud;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.cloud.ServiceLoadBalancer;
+import org.apache.camel.cloud.ServiceLoadBalancerFactory;
+
+public class DefaultServiceLoadBalancerFactory implements ServiceLoadBalancerFactory {
+
+    @Override
+    public ServiceLoadBalancer newInstance(CamelContext camelContext) throws Exception {
+        DefaultServiceLoadBalancer loadBalancer = new DefaultServiceLoadBalancer();
+        loadBalancer.setCamelContext(camelContext);
+
+        return loadBalancer;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/model/cloud/DefaultServiceCallLoadBalancerConfiguration.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/cloud/DefaultServiceCallLoadBalancerConfiguration.java b/camel-core/src/main/java/org/apache/camel/model/cloud/DefaultServiceCallLoadBalancerConfiguration.java
deleted file mode 100644
index 4c3dae4..0000000
--- a/camel-core/src/main/java/org/apache/camel/model/cloud/DefaultServiceCallLoadBalancerConfiguration.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.camel.model.cloud;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.camel.spi.Metadata;
-
-@Metadata(label = "routing,cloud,load-balancing")
-@XmlRootElement(name = "defaultLoadBalancer")
-@XmlAccessorType(XmlAccessType.FIELD)
-public class DefaultServiceCallLoadBalancerConfiguration extends ServiceCallLoadBalancerConfiguration {
-    public DefaultServiceCallLoadBalancerConfiguration() {
-        this(null);
-    }
-
-    public DefaultServiceCallLoadBalancerConfiguration(ServiceCallDefinition parent) {
-        super(parent, "default-load-balancer");
-    }
-
-    // *************************************************************************
-    // Properties
-    // *************************************************************************
-
-
-    // *************************************************************************
-    // Fluent API
-    // *************************************************************************
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/model/cloud/DefaultServiceCallServiceLoadBalancerConfiguration.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/cloud/DefaultServiceCallServiceLoadBalancerConfiguration.java b/camel-core/src/main/java/org/apache/camel/model/cloud/DefaultServiceCallServiceLoadBalancerConfiguration.java
new file mode 100644
index 0000000..038a5b1
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/model/cloud/DefaultServiceCallServiceLoadBalancerConfiguration.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.model.cloud;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.camel.spi.Metadata;
+
+@Metadata(label = "routing,cloud,load-balancing")
+@XmlRootElement(name = "defaultLoadBalancer")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class DefaultServiceCallServiceLoadBalancerConfiguration extends ServiceCallServiceLoadBalancerConfiguration {
+    public DefaultServiceCallServiceLoadBalancerConfiguration() {
+        this(null);
+    }
+
+    public DefaultServiceCallServiceLoadBalancerConfiguration(ServiceCallDefinition parent) {
+        super(parent, "default-service-load-balancer");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/model/cloud/RibbonServiceCallLoadBalancerConfiguration.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/cloud/RibbonServiceCallLoadBalancerConfiguration.java b/camel-core/src/main/java/org/apache/camel/model/cloud/RibbonServiceCallLoadBalancerConfiguration.java
deleted file mode 100644
index b605890..0000000
--- a/camel-core/src/main/java/org/apache/camel/model/cloud/RibbonServiceCallLoadBalancerConfiguration.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.model.cloud;
-
-import java.util.Map;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.spi.Metadata;
-
-@Metadata(label = "routing,cloud,load-balancing")
-@XmlRootElement(name = "ribbonLoadBalancer")
-@XmlAccessorType(XmlAccessType.FIELD)
-public class RibbonServiceCallLoadBalancerConfiguration extends ServiceCallLoadBalancerConfiguration {
-    @XmlAttribute
-    private String namespace;
-    @XmlAttribute
-    private String username;
-    @XmlAttribute
-    private String password;
-    @XmlAttribute
-    private String clientName;
-
-    public RibbonServiceCallLoadBalancerConfiguration() {
-        this(null);
-    }
-
-    public RibbonServiceCallLoadBalancerConfiguration(ServiceCallDefinition parent) {
-        super(parent, "ribbon-load-balancer");
-    }
-
-    // *************************************************************************
-    // Properties
-    // *************************************************************************
-
-    public String getNamespace() {
-        return namespace;
-    }
-
-    /**
-     * The namespace
-     */
-    public void setNamespace(String namespace) {
-        this.namespace = namespace;
-    }
-
-    public String getUsername() {
-        return username;
-    }
-
-    /**
-     * The username
-     */
-    public void setUsername(String username) {
-        this.username = username;
-    }
-
-    public String getPassword() {
-        return password;
-    }
-
-    /**
-     * The password
-     */
-    public void setPassword(String password) {
-        this.password = password;
-    }
-
-    public String getClientName() {
-        return clientName;
-    }
-
-    /**
-     * Sets the Ribbon client name
-     */
-    public void setClientName(String clientName) {
-        this.clientName = clientName;
-    }
-
-    // *************************************************************************
-    // Fluent API
-    // *************************************************************************
-
-    /**
-     * Sets the namespace
-     */
-    public RibbonServiceCallLoadBalancerConfiguration namespace(String namespace) {
-        setNamespace(namespace);
-        return this;
-    }
-
-    /**
-     * Sets the username
-     */
-    public RibbonServiceCallLoadBalancerConfiguration username(String username) {
-        setUsername(username);
-        return this;
-    }
-
-    /**
-     * Sets the password
-     */
-    public RibbonServiceCallLoadBalancerConfiguration password(String password) {
-        setPassword(password);
-        return this;
-    }
-
-    /**
-     * Sets the Ribbon client name
-     */
-    public RibbonServiceCallLoadBalancerConfiguration clientName(String clientName) {
-        setClientName(clientName);
-        return this;
-    }
-
-    // *************************************************************************
-    // Helpers
-    // *************************************************************************
-
-    @Override
-    protected void postProcessFactoryParameters(CamelContext camelContext, Map<String, Object> parameters) throws Exception  {
-        Map<String, Object> properties = (Map<String, Object>)parameters.get("properties");
-        if (properties != null) {
-            parameters.put("clientConfig", properties);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/model/cloud/RibbonServiceCallServiceLoadBalancerConfiguration.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/cloud/RibbonServiceCallServiceLoadBalancerConfiguration.java b/camel-core/src/main/java/org/apache/camel/model/cloud/RibbonServiceCallServiceLoadBalancerConfiguration.java
new file mode 100644
index 0000000..b6bd68b
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/model/cloud/RibbonServiceCallServiceLoadBalancerConfiguration.java
@@ -0,0 +1,130 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.model.cloud;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.camel.spi.Metadata;
+
+@Metadata(label = "routing,cloud,load-balancing")
+@XmlRootElement(name = "ribbonLoadBalancer")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class RibbonServiceCallServiceLoadBalancerConfiguration extends ServiceCallServiceLoadBalancerConfiguration {
+    @XmlAttribute
+    private String namespace;
+    @XmlAttribute
+    private String username;
+    @XmlAttribute
+    private String password;
+    @XmlAttribute
+    private String clientName;
+
+    public RibbonServiceCallServiceLoadBalancerConfiguration() {
+        this(null);
+    }
+
+    public RibbonServiceCallServiceLoadBalancerConfiguration(ServiceCallDefinition parent) {
+        super(parent, "ribbon-service-load-balancer");
+    }
+
+    // *************************************************************************
+    // Properties
+    // *************************************************************************
+
+    public String getNamespace() {
+        return namespace;
+    }
+
+    /**
+     * The namespace
+     */
+    public void setNamespace(String namespace) {
+        this.namespace = namespace;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    /**
+     * The username
+     */
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    /**
+     * The password
+     */
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public String getClientName() {
+        return clientName;
+    }
+
+    /**
+     * Sets the Ribbon client name
+     */
+    public void setClientName(String clientName) {
+        this.clientName = clientName;
+    }
+
+    // *************************************************************************
+    // Fluent API
+    // *************************************************************************
+
+    /**
+     * Sets the namespace
+     */
+    public RibbonServiceCallServiceLoadBalancerConfiguration namespace(String namespace) {
+        setNamespace(namespace);
+        return this;
+    }
+
+    /**
+     * Sets the username
+     */
+    public RibbonServiceCallServiceLoadBalancerConfiguration username(String username) {
+        setUsername(username);
+        return this;
+    }
+
+    /**
+     * Sets the password
+     */
+    public RibbonServiceCallServiceLoadBalancerConfiguration password(String password) {
+        setPassword(password);
+        return this;
+    }
+
+    /**
+     * Sets the Ribbon client name
+     */
+    public RibbonServiceCallServiceLoadBalancerConfiguration clientName(String clientName) {
+        setClientName(clientName);
+        return this;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallConfigurationDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallConfigurationDefinition.java b/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallConfigurationDefinition.java
index 73950fe..a590676 100644
--- a/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallConfigurationDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallConfigurationDefinition.java
@@ -27,10 +27,10 @@ import javax.xml.bind.annotation.XmlTransient;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.Expression;
 import org.apache.camel.builder.ExpressionClause;
-import org.apache.camel.cloud.LoadBalancer;
 import org.apache.camel.cloud.ServiceChooser;
 import org.apache.camel.cloud.ServiceDiscovery;
 import org.apache.camel.cloud.ServiceFilter;
+import org.apache.camel.cloud.ServiceLoadBalancer;
 import org.apache.camel.model.IdentifiedType;
 import org.apache.camel.spi.Metadata;
 
@@ -62,7 +62,7 @@ public class ServiceCallConfigurationDefinition extends IdentifiedType {
     @XmlAttribute
     private String loadBalancerRef;
     @XmlTransient
-    private LoadBalancer loadBalancer;
+    private ServiceLoadBalancer loadBalancer;
     @XmlAttribute
     private String expressionRef;
     @XmlTransient
@@ -88,10 +88,10 @@ public class ServiceCallConfigurationDefinition extends IdentifiedType {
     private ServiceCallServiceFilterConfiguration serviceFilterConfiguration;
 
     @XmlElements({
-        @XmlElement(name = "ribbonLoadBalancer", type = RibbonServiceCallLoadBalancerConfiguration.class),
-        @XmlElement(name = "defaultLoadBalancer", type = DefaultServiceCallLoadBalancerConfiguration.class) }
+        @XmlElement(name = "ribbonLoadBalancer", type = RibbonServiceCallServiceLoadBalancerConfiguration.class),
+        @XmlElement(name = "defaultLoadBalancer", type = DefaultServiceCallServiceLoadBalancerConfiguration.class) }
     )
-    private ServiceCallLoadBalancerConfiguration loadBalancerConfiguration;
+    private ServiceCallServiceLoadBalancerConfiguration loadBalancerConfiguration;
 
     @XmlElements({
         @XmlElement(name = "expression", type = ServiceCallExpressionConfiguration.class)}
@@ -207,20 +207,20 @@ public class ServiceCallConfigurationDefinition extends IdentifiedType {
     }
 
     /**
-     * Sets a reference to a custom {@link LoadBalancer} to use.
+     * Sets a reference to a custom {@link ServiceLoadBalancer} to use.
      */
     public void setLoadBalancerRef(String loadBalancerRef) {
         this.loadBalancerRef = loadBalancerRef;
     }
 
-    public LoadBalancer getLoadBalancer() {
+    public ServiceLoadBalancer getLoadBalancer() {
         return loadBalancer;
     }
 
     /**
-     * Sets a custom {@link LoadBalancer} to use.
+     * Sets a custom {@link ServiceLoadBalancer} to use.
      */
-    public void setLoadBalancer(LoadBalancer loadBalancer) {
+    public void setLoadBalancer(ServiceLoadBalancer loadBalancer) {
         this.loadBalancer = loadBalancer;
     }
 
@@ -268,14 +268,14 @@ public class ServiceCallConfigurationDefinition extends IdentifiedType {
         this.serviceFilterConfiguration = serviceFilterConfiguration;
     }
 
-    public ServiceCallLoadBalancerConfiguration getLoadBalancerConfiguration() {
+    public ServiceCallServiceLoadBalancerConfiguration getLoadBalancerConfiguration() {
         return loadBalancerConfiguration;
     }
 
     /**
      * Configures theL oadBalancer using the given configuration.
      */
-    public void setLoadBalancerConfiguration(ServiceCallLoadBalancerConfiguration loadBalancerConfiguration) {
+    public void setLoadBalancerConfiguration(ServiceCallServiceLoadBalancerConfiguration loadBalancerConfiguration) {
         this.loadBalancerConfiguration = loadBalancerConfiguration;
     }
 
@@ -374,7 +374,7 @@ public class ServiceCallConfigurationDefinition extends IdentifiedType {
     }
 
     /**
-     * Sets a reference to a custom {@link LoadBalancer} to use.
+     * Sets a reference to a custom {@link ServiceLoadBalancer} to use.
      */
     public ServiceCallConfigurationDefinition loadBalancer(String loadBalancerRef) {
         setLoadBalancerRef(loadBalancerRef);
@@ -382,9 +382,9 @@ public class ServiceCallConfigurationDefinition extends IdentifiedType {
     }
 
     /**
-     * Sets a custom {@link LoadBalancer} to use.
+     * Sets a custom {@link ServiceLoadBalancer} to use.
      */
-    public ServiceCallConfigurationDefinition loadBalancer(LoadBalancer loadBalancer) {
+    public ServiceCallConfigurationDefinition loadBalancer(ServiceLoadBalancer loadBalancer) {
         setLoadBalancer(loadBalancer);
         return this;
     }
@@ -436,7 +436,7 @@ public class ServiceCallConfigurationDefinition extends IdentifiedType {
     /**
      * Configures the LoadBalancer using the given configuration.
      */
-    public ServiceCallConfigurationDefinition loadBalancerConfiguration(ServiceCallLoadBalancerConfiguration loadBalancerConfiguration) {
+    public ServiceCallConfigurationDefinition loadBalancerConfiguration(ServiceCallServiceLoadBalancerConfiguration loadBalancerConfiguration) {
         setLoadBalancerConfiguration(loadBalancerConfiguration);
         return this;
     }
@@ -610,21 +610,21 @@ public class ServiceCallConfigurationDefinition extends IdentifiedType {
     // *****************************
 
     public ServiceCallConfigurationDefinition defaultLoadBalancer() {
-        DefaultServiceCallLoadBalancerConfiguration conf = new DefaultServiceCallLoadBalancerConfiguration();
+        DefaultServiceCallServiceLoadBalancerConfiguration conf = new DefaultServiceCallServiceLoadBalancerConfiguration();
         setLoadBalancerConfiguration(conf);
 
         return this;
     }
 
     public ServiceCallConfigurationDefinition ribbonLoadBalancer() {
-        RibbonServiceCallLoadBalancerConfiguration conf = new RibbonServiceCallLoadBalancerConfiguration();
+        RibbonServiceCallServiceLoadBalancerConfiguration conf = new RibbonServiceCallServiceLoadBalancerConfiguration();
         setLoadBalancerConfiguration(conf);
 
         return this;
     }
 
     public ServiceCallConfigurationDefinition ribbonLoadBalancer(String clientName) {
-        RibbonServiceCallLoadBalancerConfiguration conf = new RibbonServiceCallLoadBalancerConfiguration();
+        RibbonServiceCallServiceLoadBalancerConfiguration conf = new RibbonServiceCallServiceLoadBalancerConfiguration();
         conf.setClientName(clientName);
 
         setLoadBalancerConfiguration(conf);

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallDefinition.java b/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallDefinition.java
index efaf03e..4da35fc 100644
--- a/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallDefinition.java
@@ -32,16 +32,16 @@ import org.apache.camel.ExchangePattern;
 import org.apache.camel.Expression;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.ExpressionClause;
-import org.apache.camel.cloud.LoadBalancer;
 import org.apache.camel.cloud.ServiceChooser;
 import org.apache.camel.cloud.ServiceChooserAware;
 import org.apache.camel.cloud.ServiceDiscovery;
 import org.apache.camel.cloud.ServiceDiscoveryAware;
 import org.apache.camel.cloud.ServiceFilter;
 import org.apache.camel.cloud.ServiceFilterAware;
-import org.apache.camel.impl.cloud.DefaultLoadBalancer;
+import org.apache.camel.cloud.ServiceLoadBalancer;
 import org.apache.camel.impl.cloud.DefaultServiceCallExpression;
 import org.apache.camel.impl.cloud.DefaultServiceCallProcessor;
+import org.apache.camel.impl.cloud.DefaultServiceLoadBalancer;
 import org.apache.camel.impl.cloud.HealthyServiceFilter;
 import org.apache.camel.impl.cloud.PassThroughServiceFilter;
 import org.apache.camel.impl.cloud.RandomServiceChooser;
@@ -87,7 +87,7 @@ public class ServiceCallDefinition extends NoOutputDefinition<ServiceCallDefinit
     @XmlAttribute
     private String loadBalancerRef;
     @XmlTransient
-    private LoadBalancer loadBalancer;
+    private ServiceLoadBalancer loadBalancer;
     @XmlAttribute
     private String expressionRef;
     @XmlTransient
@@ -114,10 +114,10 @@ public class ServiceCallDefinition extends NoOutputDefinition<ServiceCallDefinit
     private ServiceCallServiceFilterConfiguration serviceFilterConfiguration;
 
     @XmlElements({
-        @XmlElement(name = "ribbonLoadBalancer", type = RibbonServiceCallLoadBalancerConfiguration.class),
-        @XmlElement(name = "defaultLoadBalancer", type = DefaultServiceCallLoadBalancerConfiguration.class) }
+        @XmlElement(name = "ribbonLoadBalancer", type = RibbonServiceCallServiceLoadBalancerConfiguration.class),
+        @XmlElement(name = "defaultLoadBalancer", type = DefaultServiceCallServiceLoadBalancerConfiguration.class) }
     )
-    private ServiceCallLoadBalancerConfiguration loadBalancerConfiguration;
+    private ServiceCallServiceLoadBalancerConfiguration loadBalancerConfiguration;
 
     @XmlElements({
         @XmlElement(name = "expressionConfiguration", type = ServiceCallExpressionConfiguration.class)}
@@ -268,20 +268,20 @@ public class ServiceCallDefinition extends NoOutputDefinition<ServiceCallDefinit
     }
 
     /**
-     * Sets a reference to a custom {@link LoadBalancer} to use.
+     * Sets a reference to a custom {@link ServiceLoadBalancer} to use.
      */
     public void setLoadBalancerRef(String loadBalancerRef) {
         this.loadBalancerRef = loadBalancerRef;
     }
 
-    public LoadBalancer getLoadBalancer() {
+    public ServiceLoadBalancer getLoadBalancer() {
         return loadBalancer;
     }
 
     /**
-     * Sets a custom {@link LoadBalancer} to use.
+     * Sets a custom {@link ServiceLoadBalancer} to use.
      */
-    public void setLoadBalancer(LoadBalancer loadBalancer) {
+    public void setLoadBalancer(ServiceLoadBalancer loadBalancer) {
         this.loadBalancer = loadBalancer;
     }
 
@@ -329,14 +329,14 @@ public class ServiceCallDefinition extends NoOutputDefinition<ServiceCallDefinit
         this.serviceFilterConfiguration = serviceFilterConfiguration;
     }
 
-    public ServiceCallLoadBalancerConfiguration getLoadBalancerConfiguration() {
+    public ServiceCallServiceLoadBalancerConfiguration getLoadBalancerConfiguration() {
         return loadBalancerConfiguration;
     }
 
     /**
      * Configures the LoadBalancer using the given configuration.
      */
-    public void setLoadBalancerConfiguration(ServiceCallLoadBalancerConfiguration loadBalancerConfiguration) {
+    public void setLoadBalancerConfiguration(ServiceCallServiceLoadBalancerConfiguration loadBalancerConfiguration) {
         this.loadBalancerConfiguration = loadBalancerConfiguration;
     }
 
@@ -444,7 +444,7 @@ public class ServiceCallDefinition extends NoOutputDefinition<ServiceCallDefinit
     }
 
     /**
-     * Sets a reference to a custom {@link LoadBalancer} to use.
+     * Sets a reference to a custom {@link ServiceLoadBalancer} to use.
      */
     public ServiceCallDefinition loadBalancer(String loadBalancerRef) {
         setLoadBalancerRef(loadBalancerRef);
@@ -452,9 +452,9 @@ public class ServiceCallDefinition extends NoOutputDefinition<ServiceCallDefinit
     }
 
     /**
-     * Sets a custom {@link LoadBalancer} to use.
+     * Sets a custom {@link ServiceLoadBalancer} to use.
      */
-    public ServiceCallDefinition loadBalancer(LoadBalancer loadBalancer) {
+    public ServiceCallDefinition loadBalancer(ServiceLoadBalancer loadBalancer) {
         setLoadBalancer(loadBalancer);
         return this;
     }
@@ -506,7 +506,7 @@ public class ServiceCallDefinition extends NoOutputDefinition<ServiceCallDefinit
     /**
      * Configures the LoadBalancer using the given configuration.
      */
-    public ServiceCallDefinition loadBalancerConfiguration(ServiceCallLoadBalancerConfiguration loadBalancerConfiguration) {
+    public ServiceCallDefinition loadBalancerConfiguration(ServiceCallServiceLoadBalancerConfiguration loadBalancerConfiguration) {
         setLoadBalancerConfiguration(loadBalancerConfiguration);
         return this;
     }
@@ -696,21 +696,21 @@ public class ServiceCallDefinition extends NoOutputDefinition<ServiceCallDefinit
     // *****************************
 
     public ServiceCallDefinition defaultLoadBalancer() {
-        DefaultServiceCallLoadBalancerConfiguration conf = new DefaultServiceCallLoadBalancerConfiguration();
+        DefaultServiceCallServiceLoadBalancerConfiguration conf = new DefaultServiceCallServiceLoadBalancerConfiguration();
         setLoadBalancerConfiguration(conf);
 
         return this;
     }
 
     public ServiceCallDefinition ribbonLoadBalancer() {
-        RibbonServiceCallLoadBalancerConfiguration conf = new RibbonServiceCallLoadBalancerConfiguration(this);
+        RibbonServiceCallServiceLoadBalancerConfiguration conf = new RibbonServiceCallServiceLoadBalancerConfiguration(this);
         setLoadBalancerConfiguration(conf);
 
         return this;
     }
 
     public ServiceCallDefinition ribbonLoadBalancer(String clientName) {
-        RibbonServiceCallLoadBalancerConfiguration conf = new RibbonServiceCallLoadBalancerConfiguration(this);
+        RibbonServiceCallServiceLoadBalancerConfiguration conf = new RibbonServiceCallServiceLoadBalancerConfiguration(this);
         conf.setClientName(clientName);
 
         setLoadBalancerConfiguration(conf);
@@ -728,7 +728,7 @@ public class ServiceCallDefinition extends NoOutputDefinition<ServiceCallDefinit
         final ServiceDiscovery serviceDiscovery = retrieveServiceDiscovery(camelContext);
         final ServiceFilter serviceFilter = retrieveServiceFilter(camelContext);
         final ServiceChooser serviceChooser = retrieveServiceChooser(camelContext);
-        final LoadBalancer loadBalancer = retrieveLoadBalancer(camelContext);
+        final ServiceLoadBalancer loadBalancer = retrieveLoadBalancer(camelContext);
         final Expression expression = retrieveExpression(camelContext);
 
         if (loadBalancer instanceof CamelContextAware) {
@@ -981,8 +981,8 @@ public class ServiceCallDefinition extends NoOutputDefinition<ServiceCallDefinit
     // LoadBalancer
     // ******************************************
 
-    private LoadBalancer retrieveLoadBalancer(CamelContext camelContext, Function<CamelContext, ServiceCallConfigurationDefinition> function) throws Exception {
-        LoadBalancer answer = null;
+    private ServiceLoadBalancer retrieveLoadBalancer(CamelContext camelContext, Function<CamelContext, ServiceCallConfigurationDefinition> function) throws Exception {
+        ServiceLoadBalancer answer = null;
 
         ServiceCallConfigurationDefinition config = function.apply(camelContext);
         if (config != null) {
@@ -990,7 +990,7 @@ public class ServiceCallDefinition extends NoOutputDefinition<ServiceCallDefinit
                 answer = config.getLoadBalancerConfiguration().newInstance(camelContext);
             } else {
                 answer = retrieve(
-                    LoadBalancer.class,
+                    ServiceLoadBalancer.class,
                     camelContext,
                     config::getLoadBalancer,
                     config::getLoadBalancerRef
@@ -1001,22 +1001,22 @@ public class ServiceCallDefinition extends NoOutputDefinition<ServiceCallDefinit
         return answer;
     }
 
-    private LoadBalancer retrieveLoadBalancer(CamelContext camelContext) throws Exception {
+    private ServiceLoadBalancer retrieveLoadBalancer(CamelContext camelContext) throws Exception {
         return Suppliers.firstNotNull(
             () -> (loadBalancerConfiguration != null) ? loadBalancerConfiguration.newInstance(camelContext) : null,
             // Local configuration
-            () -> retrieve(LoadBalancer.class, camelContext, this::getLoadBalancer, this::getLoadBalancerRef),
+            () -> retrieve(ServiceLoadBalancer.class, camelContext, this::getLoadBalancer, this::getLoadBalancerRef),
             // Linked configuration
             () -> retrieveLoadBalancer(camelContext, this::retrieveConfig),
             // Default configuration
             () -> retrieveLoadBalancer(camelContext, this::retrieveDefaultConfig),
             // Check if there is a single instance in the registry
-            () -> findByType(camelContext, LoadBalancer.class),
+            () -> findByType(camelContext, ServiceLoadBalancer.class),
             // From registry
-            () -> lookup(camelContext, ServiceCallConstants.DEFAULT_LOAD_BALANCER_ID, LoadBalancer.class)
+            () -> lookup(camelContext, ServiceCallConstants.DEFAULT_LOAD_BALANCER_ID, ServiceLoadBalancer.class)
         ).orElseGet(
             // Default
-            () -> new DefaultLoadBalancer()
+            () -> new DefaultServiceLoadBalancer()
         );
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallExpressionConfiguration.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallExpressionConfiguration.java b/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallExpressionConfiguration.java
index 2c1838f..8a76a69 100644
--- a/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallExpressionConfiguration.java
+++ b/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallExpressionConfiguration.java
@@ -247,6 +247,8 @@ public class ServiceCallExpressionConfiguration extends IdentifiedType implement
                 try {
                     Map<String, Object> parameters = new HashMap<>();
                     IntrospectionSupport.getProperties(this, parameters, null, false);
+
+                    // Convert properties to Map<String, String>
                     parameters.put("properties", getPropertiesAsMap(camelContext));
 
                     postProcessFactoryParameters(camelContext, parameters);

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallLoadBalancerConfiguration.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallLoadBalancerConfiguration.java b/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallLoadBalancerConfiguration.java
deleted file mode 100644
index 42f644a..0000000
--- a/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallLoadBalancerConfiguration.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.camel.model.cloud;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlTransient;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.NoFactoryAvailableException;
-import org.apache.camel.cloud.LoadBalancer;
-import org.apache.camel.cloud.LoadBalancerFactory;
-import org.apache.camel.model.IdentifiedType;
-import org.apache.camel.model.ProcessorDefinition;
-import org.apache.camel.model.PropertyDefinition;
-import org.apache.camel.spi.Metadata;
-import org.apache.camel.util.CamelContextHelper;
-import org.apache.camel.util.IntrospectionSupport;
-import org.apache.camel.util.ObjectHelper;
-
-@Metadata(label = "routing,cloud,load-balancing")
-@XmlRootElement(name = "loadBalancerConfiguration")
-@XmlAccessorType(XmlAccessType.FIELD)
-public class ServiceCallLoadBalancerConfiguration extends IdentifiedType implements LoadBalancerFactory {
-    private static final String RESOURCE_PATH = "META-INF/services/org/apache/camel/cloud/";
-
-    @XmlTransient
-    private final ServiceCallDefinition parent;
-    @XmlTransient
-    private final String factoryKey;
-    @XmlElement(name = "properties") @Metadata(label = "advanced")
-    private List<PropertyDefinition> properties;
-
-    public ServiceCallLoadBalancerConfiguration() {
-        this(null, null);
-    }
-
-    public ServiceCallLoadBalancerConfiguration(ServiceCallDefinition parent, String factoryKey) {
-        this.parent = parent;
-        this.factoryKey = factoryKey;
-    }
-
-    public ServiceCallDefinition end() {
-        return this.parent;
-    }
-
-    public ProcessorDefinition<?> endParent() {
-        return this.parent.end();
-    }
-
-    // *************************************************************************
-    //
-    // *************************************************************************
-
-    public List<PropertyDefinition> getProperties() {
-        return properties;
-    }
-
-    /**
-     * Set client properties to use.
-     * <p/>
-     * These properties are specific to what service call implementation are in
-     * use. For example if using ribbon, then the client properties are define
-     * in com.netflix.client.config.CommonClientConfigKey.
-     */
-    public void setProperties(List<PropertyDefinition> properties) {
-        this.properties = properties;
-    }
-
-    /**
-     * Adds a custom property to use.
-     * <p/>
-     * These properties are specific to what service call implementation are in
-     * use. For example if using ribbon, then the client properties are define
-     * in com.netflix.client.config.CommonClientConfigKey.
-     */
-    public ServiceCallLoadBalancerConfiguration property(String key, String value) {
-        if (properties == null) {
-            properties = new ArrayList<>();
-        }
-        PropertyDefinition prop = new PropertyDefinition();
-        prop.setKey(key);
-        prop.setValue(value);
-        properties.add(prop);
-        return this;
-    }
-
-    protected Map<String, String> getPropertiesAsMap(CamelContext camelContext) throws Exception {
-        Map<String, String> answer;
-
-        if (properties == null || properties.isEmpty()) {
-            answer = Collections.emptyMap();
-        } else {
-            answer = new HashMap<>();
-            for (PropertyDefinition prop : properties) {
-                // support property placeholders
-                String key = CamelContextHelper.parseText(camelContext, prop.getKey());
-                String value = CamelContextHelper.parseText(camelContext, prop.getValue());
-                answer.put(key, value);
-            }
-        }
-
-        return answer;
-    }
-
-    // *************************************************************************
-    // Factory
-    // *************************************************************************
-
-    @Override
-    public LoadBalancer newInstance(CamelContext camelContext) throws Exception {
-        ObjectHelper.notNull(factoryKey, "LoadBalancer factoryKey");
-
-        LoadBalancer answer;
-
-        // First try to find the factory from the registry.
-        LoadBalancerFactory factory = CamelContextHelper.lookup(camelContext, factoryKey, LoadBalancerFactory.class);
-        if (factory != null) {
-            // If a factory is found in the registry do not re-configure it as
-            // it should be pre-configured.
-            answer = factory.newInstance(camelContext);
-        } else {
-
-            Class<?> type;
-            try {
-                // Then use Service factory.
-                type = camelContext.getFactoryFinder(RESOURCE_PATH).findClass(factoryKey);
-            } catch (Exception e) {
-                throw new NoFactoryAvailableException(RESOURCE_PATH + factoryKey, e);
-            }
-
-            if (type != null) {
-                if (LoadBalancerFactory.class.isAssignableFrom(type)) {
-                    factory = (LoadBalancerFactory) camelContext.getInjector().newInstance(type);
-                } else {
-                    throw new IllegalArgumentException(
-                        "Resolving LoadBalancer: " + factoryKey + " detected type conflict: Not a LoadBalancerFactory implementation. Found: " + type.getName());
-                }
-            }
-
-            try {
-                Map<String, Object> parameters = new HashMap<>();
-                IntrospectionSupport.getProperties(this, parameters, null, false);
-                parameters.put("properties", getPropertiesAsMap(camelContext));
-
-                postProcessFactoryParameters(camelContext, parameters);
-
-                IntrospectionSupport.setProperties(factory, parameters);
-
-                answer = factory.newInstance(camelContext);
-            } catch (Exception e) {
-                throw new IllegalArgumentException(e);
-            }
-        }
-
-        return answer;
-    }
-
-    // *************************************************************************
-    // Utilities
-    // *************************************************************************
-
-    protected void postProcessFactoryParameters(CamelContext camelContext, Map<String, Object> parameters) throws Exception  {
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceChooserConfiguration.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceChooserConfiguration.java b/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceChooserConfiguration.java
index 0a0d8f4..b6c6e7e 100644
--- a/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceChooserConfiguration.java
+++ b/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceChooserConfiguration.java
@@ -163,8 +163,12 @@ public class ServiceCallServiceChooserConfiguration extends IdentifiedType imple
             try {
                 Map<String, Object> parameters = new HashMap<>();
                 IntrospectionSupport.getProperties(this, parameters, null, false);
+
+                // Convert properties to Map<String, String>
                 parameters.put("properties", getPropertiesAsMap(camelContext));
 
+                postProcessFactoryParameters(camelContext, parameters);
+
                 IntrospectionSupport.setProperties(factory, parameters);
 
                 answer = factory.newInstance(camelContext);

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceDiscoveryConfiguration.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceDiscoveryConfiguration.java b/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceDiscoveryConfiguration.java
index b6e59df..baf1773 100644
--- a/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceDiscoveryConfiguration.java
+++ b/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceDiscoveryConfiguration.java
@@ -170,6 +170,8 @@ public class ServiceCallServiceDiscoveryConfiguration extends IdentifiedType imp
             try {
                 Map<String, Object> parameters = new HashMap<>();
                 IntrospectionSupport.getProperties(this, parameters, null, false);
+
+                // Convert properties to Map<String, String>
                 parameters.put("properties", getPropertiesAsMap(camelContext));
 
                 postProcessFactoryParameters(camelContext, parameters);

http://git-wip-us.apache.org/repos/asf/camel/blob/ecc81927/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceFilterConfiguration.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceFilterConfiguration.java b/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceFilterConfiguration.java
index 6b6de0c..b5dc423 100644
--- a/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceFilterConfiguration.java
+++ b/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallServiceFilterConfiguration.java
@@ -163,6 +163,8 @@ public class ServiceCallServiceFilterConfiguration extends IdentifiedType implem
             try {
                 Map<String, Object> parameters = new HashMap<>();
                 IntrospectionSupport.getProperties(this, parameters, null, false);
+
+                // Convert properties to Map<String, String>
                 parameters.put("properties", getPropertiesAsMap(camelContext));
 
                 postProcessFactoryParameters(camelContext, parameters);


[4/4] camel git commit: ServiceCall : add documentation about LoadBalancer in ServiceCall EIP doc

Posted by lb...@apache.org.
ServiceCall : add documentation about LoadBalancer in ServiceCall EIP doc


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

Branch: refs/heads/master
Commit: 3e7b1cfdd4a69b45a51b2505ad4079e32a0ff9d1
Parents: ecc8192
Author: lburgazzoli <lb...@gmail.com>
Authored: Wed Apr 19 18:15:17 2017 +0200
Committer: lburgazzoli <lb...@gmail.com>
Committed: Wed Apr 19 18:15:17 2017 +0200

----------------------------------------------------------------------
 .../src/main/docs/eips/serviceCall-eip.adoc     | 97 ++++++++++++++++++++
 1 file changed, 97 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3e7b1cfd/camel-core/src/main/docs/eips/serviceCall-eip.adoc
----------------------------------------------------------------------
diff --git a/camel-core/src/main/docs/eips/serviceCall-eip.adoc b/camel-core/src/main/docs/eips/serviceCall-eip.adoc
index 35965ea..0874eef 100644
--- a/camel-core/src/main/docs/eips/serviceCall-eip.adoc
+++ b/camel-core/src/main/docs/eips/serviceCall-eip.adoc
@@ -334,6 +334,89 @@ from("direct:start")
 </camelContext>
 ----
 
+### Load Balancer
+
+The Service Call EIP comes with its own Load Balancer which is istantiated by default if a custome one is not configured and glues Service Discovery, Service Filer, Service Chooser and Service Expression togheter to load balance requests among the available services.
+
+If you need a more sophisticate load balancer you can use Ribbon by adding camel-ribbon to the mix, maven users will need to add the following dependency to their pom.xml
+
+[source,xml]
+----
+<dependency>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-ribbon</artifactId>
+    <!-- use the same version as your Camel core version -->
+    <version>x.y.z</version>
+</dependency>
+----
+
+*Available options:*
+
+[width="100%",cols="3,1m,6",options="header"]
+|=======================================================================
+| Name | Java Type | Description
+| clientName | String | The Ribbon client name
+| roperties | List<PropertyDefinition> | Custom client config properties
+|=======================================================================
+
+To leverage Ribbon, it is required to explicit enable it:
+
+[source,java]
+.Java DSL
+----
+from("direct:start")
+    .serviceCall("foo")
+        .ribbonLoadBalancer()
+    .to("mock:result");
+----
+
+[source,xml]
+.XML DSL
+----
+<camelContext xmlns="http://camel.apache.org/schema/spring">
+  <route>
+    <from uri="direct:start"/>
+    <serviceCall name="foo">
+      <ribbonLoadBalancer/>
+    </serviceCall>
+    <to uri="mock:result"/>
+  </route>
+</camelContext>
+----
+
+
+You can configure Ribbon key programmaticaly using RibbonConfiguration:
+
+[source,java]
+.Java DSL
+----
+RibbonConfiguration configuration = new RibbonConfiguration();
+configuration.addProperty("listOfServers", "localhost:9090,localhost:9091");
+
+from("direct:start")
+    .serviceCall("foo")
+        .loadBalancer(new RibbonServiceLoadBalancer(configuration))
+    .to("mock:result");
+----
+
+Or leveraging XML specific configuration:
+
+[source,xml]
+.XML DSL
+----
+<camelContext xmlns="http://camel.apache.org/schema/spring">
+  <route>
+    <from uri="direct:start"/>
+    <serviceCall name="foo">
+      <ribbonLoadBalancer>
+          <properties key="listOfServers" value="localhost:9090,localhost:9091"/>
+      </ribbonLoadBalancer>
+    </serviceCall>
+    <to uri="mock:result"/>
+  </route>
+</camelContext>
+----
+
 ### Shared configurations
 
 The Service CAll EIP can be configured straight on the route definition or through shared configurations, here an example with two configurations registered in the Camel Context:
@@ -418,3 +501,17 @@ public class MyRouteBuilder implements RouteBuilder {
     }
 }
 ----
+
+### Spring Cloud support
+
+If you are using Camel in an application based on Spring Cloud, you can leverage Spring Cloud service discovery and load balancing capabilities by adding the Spring Cloud related dependencies (i.e. spring-cloud-consul, spring-cloud-kubernetes) as any Spring Boot/Cloud application in addition to Camel's own camel-spring-cloud dependency.
+
+[source,xml]
+----
+<dependency>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-spring-cloud dependency</artifactId>
+    <!-- use the same version as your Camel core version -->
+    <version>x.y.z</version>
+</dependency>
+----