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 <[email protected]> Authored: Wed Apr 19 13:36:19 2017 +0200 Committer: lburgazzoli <[email protected]> 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);
