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/03/31 15:59:07 UTC
camel git commit: Refactor service-discovery aggregation
Repository: camel
Updated Branches:
refs/heads/master 28a156753 -> daca8394b
Refactor service-discovery aggregation
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/daca8394
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/daca8394
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/daca8394
Branch: refs/heads/master
Commit: daca8394b507d3a56301b6a955ccc2d220be2224
Parents: 28a1567
Author: lburgazzoli <lb...@gmail.com>
Authored: Fri Mar 31 17:58:42 2017 +0200
Committer: lburgazzoli <lb...@gmail.com>
Committed: Fri Mar 31 17:58:42 2017 +0200
----------------------------------------------------------------------
.../impl/cloud/AggregatingServiceDiscovery.java | 52 ++++++
.../AggregatingServiceDiscoveryFactory.java | 54 ++++++
.../impl/cloud/ChainedServiceDiscovery.java | 52 ------
.../cloud/ChainedServiceDiscoveryFactory.java | 54 ------
...erviceCallServiceDiscoveryConfiguration.java | 169 +++++++++++++++++++
...erviceCallServiceDiscoveryConfiguration.java | 6 +-
...erviceCallServiceDiscoveryConfiguration.java | 169 -------------------
.../ServiceCallConfigurationDefinition.java | 8 +-
.../model/cloud/ServiceCallDefinition.java | 6 +-
.../camel/cloud/aggregating-service-discovery | 17 ++
.../camel/cloud/chained-service-discovery | 17 --
.../org/apache/camel/model/cloud/jaxb.index | 2 +-
.../cloud/AggregatingServiceDiscoveryTest.java | 71 ++++++++
.../impl/cloud/ChainedServiceDiscoveryTest.java | 71 --------
.../boot/cloud/CamelCloudServiceDiscovery.java | 4 +-
...lCloudServiceDiscoveryAutoConfiguration.java | 17 +-
...amelCloudServiceFilterAutoConfiguration.java | 14 +-
.../cloud/ServiceCallConfigurationTest.java | 4 +-
.../cloud/ServiceCallConfigurationTest.xml | 4 +-
19 files changed, 396 insertions(+), 395 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/daca8394/camel-core/src/main/java/org/apache/camel/impl/cloud/AggregatingServiceDiscovery.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/cloud/AggregatingServiceDiscovery.java b/camel-core/src/main/java/org/apache/camel/impl/cloud/AggregatingServiceDiscovery.java
new file mode 100644
index 0000000..12d16f1
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/impl/cloud/AggregatingServiceDiscovery.java
@@ -0,0 +1,52 @@
+/**
+ * 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.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.apache.camel.cloud.ServiceDefinition;
+import org.apache.camel.cloud.ServiceDiscovery;
+
+public class AggregatingServiceDiscovery implements ServiceDiscovery {
+ private final List<ServiceDiscovery> delegates;
+
+ public AggregatingServiceDiscovery(List<ServiceDiscovery> delegates) {
+ this.delegates = Collections.unmodifiableList(delegates);
+ }
+
+ public List<ServiceDiscovery> getDelegates() {
+ return this.delegates;
+ }
+
+ @Override
+ public List<ServiceDefinition> getServices(String name) {
+ return delegates.stream()
+ .flatMap(d -> d.getServices(name).stream())
+ .collect(Collectors.toList());
+ }
+
+ // **********************
+ // Helpers
+ // **********************
+
+ public static AggregatingServiceDiscovery wrap(ServiceDiscovery... delegates) {
+ return new AggregatingServiceDiscovery(Arrays.asList(delegates));
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/daca8394/camel-core/src/main/java/org/apache/camel/impl/cloud/AggregatingServiceDiscoveryFactory.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/cloud/AggregatingServiceDiscoveryFactory.java b/camel-core/src/main/java/org/apache/camel/impl/cloud/AggregatingServiceDiscoveryFactory.java
new file mode 100644
index 0000000..1364261
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/impl/cloud/AggregatingServiceDiscoveryFactory.java
@@ -0,0 +1,54 @@
+/**
+ * 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 org.apache.camel.CamelContext;
+import org.apache.camel.cloud.ServiceDiscovery;
+import org.apache.camel.cloud.ServiceDiscoveryFactory;
+import org.apache.camel.util.ObjectHelper;
+
+public class AggregatingServiceDiscoveryFactory implements ServiceDiscoveryFactory {
+ private List<ServiceDiscovery> serviceDiscoveryList;
+
+ public AggregatingServiceDiscoveryFactory() {
+ }
+
+ // *************************************************************************
+ // Properties
+ // *************************************************************************
+
+ public List<ServiceDiscovery> getServiceDiscoveryList() {
+ return serviceDiscoveryList;
+ }
+
+ public void setServiceDiscoveryList(List<ServiceDiscovery> serviceDiscoveryList) {
+ this.serviceDiscoveryList = serviceDiscoveryList;
+ }
+
+ // *************************************************************************
+ // Factory
+ // *************************************************************************
+
+ @Override
+ public ServiceDiscovery newInstance(CamelContext camelContext) throws Exception {
+ ObjectHelper.notNull(serviceDiscoveryList, "ServiceDiscovery list");
+
+ return new AggregatingServiceDiscovery(serviceDiscoveryList);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/daca8394/camel-core/src/main/java/org/apache/camel/impl/cloud/ChainedServiceDiscovery.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/cloud/ChainedServiceDiscovery.java b/camel-core/src/main/java/org/apache/camel/impl/cloud/ChainedServiceDiscovery.java
deleted file mode 100644
index eee5a1f..0000000
--- a/camel-core/src/main/java/org/apache/camel/impl/cloud/ChainedServiceDiscovery.java
+++ /dev/null
@@ -1,52 +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.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import org.apache.camel.cloud.ServiceDefinition;
-import org.apache.camel.cloud.ServiceDiscovery;
-
-public class ChainedServiceDiscovery implements ServiceDiscovery {
- private final List<ServiceDiscovery> delegates;
-
- public ChainedServiceDiscovery(List<ServiceDiscovery> delegates) {
- this.delegates = Collections.unmodifiableList(delegates);
- }
-
- public List<ServiceDiscovery> getDelegates() {
- return this.delegates;
- }
-
- @Override
- public List<ServiceDefinition> getServices(String name) {
- return delegates.stream()
- .flatMap(d -> d.getServices(name).stream())
- .collect(Collectors.toList());
- }
-
- // **********************
- // Helpers
- // **********************
-
- public static ChainedServiceDiscovery wrap(ServiceDiscovery... delegates) {
- return new ChainedServiceDiscovery(Arrays.asList(delegates));
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/daca8394/camel-core/src/main/java/org/apache/camel/impl/cloud/ChainedServiceDiscoveryFactory.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/cloud/ChainedServiceDiscoveryFactory.java b/camel-core/src/main/java/org/apache/camel/impl/cloud/ChainedServiceDiscoveryFactory.java
deleted file mode 100644
index 6c8acc8..0000000
--- a/camel-core/src/main/java/org/apache/camel/impl/cloud/ChainedServiceDiscoveryFactory.java
+++ /dev/null
@@ -1,54 +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 org.apache.camel.CamelContext;
-import org.apache.camel.cloud.ServiceDiscovery;
-import org.apache.camel.cloud.ServiceDiscoveryFactory;
-import org.apache.camel.util.ObjectHelper;
-
-public class ChainedServiceDiscoveryFactory implements ServiceDiscoveryFactory {
- private List<ServiceDiscovery> serviceDiscoveryList;
-
- public ChainedServiceDiscoveryFactory() {
- }
-
- // *************************************************************************
- // Properties
- // *************************************************************************
-
- public List<ServiceDiscovery> getServiceDiscoveryList() {
- return serviceDiscoveryList;
- }
-
- public void setServiceDiscoveryList(List<ServiceDiscovery> serviceDiscoveryList) {
- this.serviceDiscoveryList = serviceDiscoveryList;
- }
-
- // *************************************************************************
- // Factory
- // *************************************************************************
-
- @Override
- public ServiceDiscovery newInstance(CamelContext camelContext) throws Exception {
- ObjectHelper.notNull(serviceDiscoveryList, "ServiceDiscovery list");
-
- return new ChainedServiceDiscovery(serviceDiscoveryList);
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/daca8394/camel-core/src/main/java/org/apache/camel/model/cloud/AggregatingServiceCallServiceDiscoveryConfiguration.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/cloud/AggregatingServiceCallServiceDiscoveryConfiguration.java b/camel-core/src/main/java/org/apache/camel/model/cloud/AggregatingServiceCallServiceDiscoveryConfiguration.java
new file mode 100644
index 0000000..b94cdc0
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/model/cloud/AggregatingServiceCallServiceDiscoveryConfiguration.java
@@ -0,0 +1,169 @@
+/**
+ * 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.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.XmlElements;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.cloud.ServiceDiscovery;
+import org.apache.camel.spi.Metadata;
+
+@Metadata(label = "routing,cloud,service-discovery")
+@XmlRootElement(name = "multiServiceDiscovery")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class AggregatingServiceCallServiceDiscoveryConfiguration extends ServiceCallServiceDiscoveryConfiguration {
+ @XmlElements({
+ @XmlElement(name = "consulServiceDiscovery", type = ConsulServiceCallServiceDiscoveryConfiguration.class),
+ @XmlElement(name = "dnsServiceDiscovery", type = DnsServiceCallServiceDiscoveryConfiguration.class),
+ @XmlElement(name = "etcdServiceDiscovery", type = EtcdServiceCallServiceDiscoveryConfiguration.class),
+ @XmlElement(name = "kubernetesServiceDiscovery", type = KubernetesServiceCallServiceDiscoveryConfiguration.class),
+ @XmlElement(name = "staticServiceDiscovery", type = StaticServiceCallServiceDiscoveryConfiguration.class),
+ @XmlElement(name = "cachingServiceDiscovery", type = CachingServiceCallServiceDiscoveryConfiguration.class)}
+ )
+ private List<ServiceCallServiceDiscoveryConfiguration> serviceDiscoveryConfigurations;
+
+ public AggregatingServiceCallServiceDiscoveryConfiguration() {
+ this(null);
+ }
+
+ public AggregatingServiceCallServiceDiscoveryConfiguration(ServiceCallDefinition parent) {
+ super(parent, "aggregating-service-discovery");
+ }
+
+ // *************************************************************************
+ // Properties
+ // *************************************************************************
+
+ public List<ServiceCallServiceDiscoveryConfiguration> getServiceDiscoveryConfigurations() {
+ return serviceDiscoveryConfigurations;
+ }
+
+ /**
+ * List of ServiceDiscovery configuration to use
+ * @param serviceDiscoveryConfigurations
+ */
+ public void setServiceDiscoveryConfigurations(List<ServiceCallServiceDiscoveryConfiguration> serviceDiscoveryConfigurations) {
+ this.serviceDiscoveryConfigurations = serviceDiscoveryConfigurations;
+ }
+
+ /**
+ * Add a ServiceDiscovery configuration
+ */
+ public void addServiceDiscoveryConfigurations(ServiceCallServiceDiscoveryConfiguration serviceDiscoveryConfiguration) {
+ if (serviceDiscoveryConfigurations == null) {
+ serviceDiscoveryConfigurations = new ArrayList<>();
+ }
+
+ serviceDiscoveryConfigurations.add(serviceDiscoveryConfiguration);
+ }
+
+ // *************************************************************************
+ // Fluent API
+ // *************************************************************************
+
+ /**
+ * List of ServiceDiscovery configuration to use
+ */
+ public AggregatingServiceCallServiceDiscoveryConfiguration serviceDiscoveryConfigurations(List<ServiceCallServiceDiscoveryConfiguration> serviceDiscoveryConfigurations) {
+ setServiceDiscoveryConfigurations(serviceDiscoveryConfigurations);
+ return this;
+ }
+
+ /**
+ * Add a ServiceDiscovery configuration
+ */
+ public AggregatingServiceCallServiceDiscoveryConfiguration serviceDiscoveryConfiguration(ServiceCallServiceDiscoveryConfiguration serviceDiscoveryConfiguration) {
+ addServiceDiscoveryConfigurations(serviceDiscoveryConfiguration);
+ return this;
+ }
+
+ // *****************************
+ // Shortcuts - ServiceDiscovery
+ // *****************************
+
+ public CachingServiceCallServiceDiscoveryConfiguration cachingServiceDiscovery() {
+ CachingServiceCallServiceDiscoveryConfiguration conf = new CachingServiceCallServiceDiscoveryConfiguration();
+ addServiceDiscoveryConfigurations(conf);
+
+ return conf;
+ }
+
+ public ConsulServiceCallServiceDiscoveryConfiguration consulServiceDiscovery() {
+ ConsulServiceCallServiceDiscoveryConfiguration conf = new ConsulServiceCallServiceDiscoveryConfiguration();
+ addServiceDiscoveryConfigurations(conf);
+
+ return conf;
+ }
+
+ public DnsServiceCallServiceDiscoveryConfiguration dnsServiceDiscovery() {
+ DnsServiceCallServiceDiscoveryConfiguration conf = new DnsServiceCallServiceDiscoveryConfiguration();
+ addServiceDiscoveryConfigurations(conf);
+
+ return conf;
+ }
+
+ public EtcdServiceCallServiceDiscoveryConfiguration etcdServiceDiscovery() {
+ EtcdServiceCallServiceDiscoveryConfiguration conf = new EtcdServiceCallServiceDiscoveryConfiguration();
+ addServiceDiscoveryConfigurations(conf);
+
+ return conf;
+ }
+
+ public KubernetesServiceCallServiceDiscoveryConfiguration kubernetesServiceDiscovery() {
+ KubernetesServiceCallServiceDiscoveryConfiguration conf = new KubernetesServiceCallServiceDiscoveryConfiguration();
+ addServiceDiscoveryConfigurations(conf);
+
+ return conf;
+ }
+
+ public AggregatingServiceCallServiceDiscoveryConfiguration multiServiceDiscovery() {
+ AggregatingServiceCallServiceDiscoveryConfiguration conf = new AggregatingServiceCallServiceDiscoveryConfiguration();
+ addServiceDiscoveryConfigurations(conf);
+
+ return conf;
+ }
+
+ public StaticServiceCallServiceDiscoveryConfiguration staticServiceDiscovery() {
+ StaticServiceCallServiceDiscoveryConfiguration conf = new StaticServiceCallServiceDiscoveryConfiguration();
+ addServiceDiscoveryConfigurations(conf);
+
+ return conf;
+ }
+
+ // *************************************************************************
+ // Utilities
+ // *************************************************************************
+
+ @Override
+ protected void postProcessFactoryParameters(final CamelContext camelContext, final Map<String, Object> parameters) throws Exception {
+ if (serviceDiscoveryConfigurations != null && !serviceDiscoveryConfigurations.isEmpty()) {
+ List<ServiceDiscovery> discoveries = new ArrayList<>(serviceDiscoveryConfigurations.size());
+ for (ServiceCallServiceDiscoveryConfiguration conf : serviceDiscoveryConfigurations) {
+ discoveries.add(conf.newInstance(camelContext));
+ }
+
+ parameters.put("serviceDiscoveryList", discoveries);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/daca8394/camel-core/src/main/java/org/apache/camel/model/cloud/CachingServiceCallServiceDiscoveryConfiguration.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/cloud/CachingServiceCallServiceDiscoveryConfiguration.java b/camel-core/src/main/java/org/apache/camel/model/cloud/CachingServiceCallServiceDiscoveryConfiguration.java
index 9b7ee98..fa6e3f6 100644
--- a/camel-core/src/main/java/org/apache/camel/model/cloud/CachingServiceCallServiceDiscoveryConfiguration.java
+++ b/camel-core/src/main/java/org/apache/camel/model/cloud/CachingServiceCallServiceDiscoveryConfiguration.java
@@ -45,7 +45,7 @@ public class CachingServiceCallServiceDiscoveryConfiguration extends ServiceCall
@XmlElement(name = "dnsServiceDiscovery", type = DnsServiceCallServiceDiscoveryConfiguration.class),
@XmlElement(name = "etcdServiceDiscovery", type = EtcdServiceCallServiceDiscoveryConfiguration.class),
@XmlElement(name = "kubernetesServiceDiscovery", type = KubernetesServiceCallServiceDiscoveryConfiguration.class),
- @XmlElement(name = "multiServiceDiscovery", type = ChainedServiceCallServiceDiscoveryConfiguration.class),
+ @XmlElement(name = "aggregatingServiceDiscovery", type = AggregatingServiceCallServiceDiscoveryConfiguration.class),
@XmlElement(name = "staticServiceDiscovery", type = StaticServiceCallServiceDiscoveryConfiguration.class)}
)
private ServiceCallServiceDiscoveryConfiguration serviceDiscoveryConfiguration;
@@ -163,8 +163,8 @@ public class CachingServiceCallServiceDiscoveryConfiguration extends ServiceCall
return conf;
}
- public ChainedServiceCallServiceDiscoveryConfiguration multiServiceDiscovery() {
- ChainedServiceCallServiceDiscoveryConfiguration conf = new ChainedServiceCallServiceDiscoveryConfiguration();
+ public AggregatingServiceCallServiceDiscoveryConfiguration aggregatingServiceDiscovery() {
+ AggregatingServiceCallServiceDiscoveryConfiguration conf = new AggregatingServiceCallServiceDiscoveryConfiguration();
setServiceDiscoveryConfiguration(conf);
return conf;
http://git-wip-us.apache.org/repos/asf/camel/blob/daca8394/camel-core/src/main/java/org/apache/camel/model/cloud/ChainedServiceCallServiceDiscoveryConfiguration.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/cloud/ChainedServiceCallServiceDiscoveryConfiguration.java b/camel-core/src/main/java/org/apache/camel/model/cloud/ChainedServiceCallServiceDiscoveryConfiguration.java
deleted file mode 100644
index 5197d0e..0000000
--- a/camel-core/src/main/java/org/apache/camel/model/cloud/ChainedServiceCallServiceDiscoveryConfiguration.java
+++ /dev/null
@@ -1,169 +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.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.XmlElements;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.cloud.ServiceDiscovery;
-import org.apache.camel.spi.Metadata;
-
-@Metadata(label = "routing,cloud,service-discovery")
-@XmlRootElement(name = "multiServiceDiscovery")
-@XmlAccessorType(XmlAccessType.FIELD)
-public class ChainedServiceCallServiceDiscoveryConfiguration extends ServiceCallServiceDiscoveryConfiguration {
- @XmlElements({
- @XmlElement(name = "consulServiceDiscovery", type = ConsulServiceCallServiceDiscoveryConfiguration.class),
- @XmlElement(name = "dnsServiceDiscovery", type = DnsServiceCallServiceDiscoveryConfiguration.class),
- @XmlElement(name = "etcdServiceDiscovery", type = EtcdServiceCallServiceDiscoveryConfiguration.class),
- @XmlElement(name = "kubernetesServiceDiscovery", type = KubernetesServiceCallServiceDiscoveryConfiguration.class),
- @XmlElement(name = "staticServiceDiscovery", type = StaticServiceCallServiceDiscoveryConfiguration.class),
- @XmlElement(name = "cachingServiceDiscovery", type = CachingServiceCallServiceDiscoveryConfiguration.class)}
- )
- private List<ServiceCallServiceDiscoveryConfiguration> serviceDiscoveryConfigurations;
-
- public ChainedServiceCallServiceDiscoveryConfiguration() {
- this(null);
- }
-
- public ChainedServiceCallServiceDiscoveryConfiguration(ServiceCallDefinition parent) {
- super(parent, "chained-service-discovery");
- }
-
- // *************************************************************************
- // Properties
- // *************************************************************************
-
- public List<ServiceCallServiceDiscoveryConfiguration> getServiceDiscoveryConfigurations() {
- return serviceDiscoveryConfigurations;
- }
-
- /**
- * List of ServiceDiscovery configuration to use
- * @param serviceDiscoveryConfigurations
- */
- public void setServiceDiscoveryConfigurations(List<ServiceCallServiceDiscoveryConfiguration> serviceDiscoveryConfigurations) {
- this.serviceDiscoveryConfigurations = serviceDiscoveryConfigurations;
- }
-
- /**
- * Add a ServiceDiscovery configuration
- */
- public void addServiceDiscoveryConfigurations(ServiceCallServiceDiscoveryConfiguration serviceDiscoveryConfiguration) {
- if (serviceDiscoveryConfigurations == null) {
- serviceDiscoveryConfigurations = new ArrayList<>();
- }
-
- serviceDiscoveryConfigurations.add(serviceDiscoveryConfiguration);
- }
-
- // *************************************************************************
- // Fluent API
- // *************************************************************************
-
- /**
- * List of ServiceDiscovery configuration to use
- */
- public ChainedServiceCallServiceDiscoveryConfiguration serviceDiscoveryConfigurations(List<ServiceCallServiceDiscoveryConfiguration> serviceDiscoveryConfigurations) {
- setServiceDiscoveryConfigurations(serviceDiscoveryConfigurations);
- return this;
- }
-
- /**
- * Add a ServiceDiscovery configuration
- */
- public ChainedServiceCallServiceDiscoveryConfiguration serviceDiscoveryConfiguration(ServiceCallServiceDiscoveryConfiguration serviceDiscoveryConfiguration) {
- addServiceDiscoveryConfigurations(serviceDiscoveryConfiguration);
- return this;
- }
-
- // *****************************
- // Shortcuts - ServiceDiscovery
- // *****************************
-
- public CachingServiceCallServiceDiscoveryConfiguration cachingServiceDiscovery() {
- CachingServiceCallServiceDiscoveryConfiguration conf = new CachingServiceCallServiceDiscoveryConfiguration();
- addServiceDiscoveryConfigurations(conf);
-
- return conf;
- }
-
- public ConsulServiceCallServiceDiscoveryConfiguration consulServiceDiscovery() {
- ConsulServiceCallServiceDiscoveryConfiguration conf = new ConsulServiceCallServiceDiscoveryConfiguration();
- addServiceDiscoveryConfigurations(conf);
-
- return conf;
- }
-
- public DnsServiceCallServiceDiscoveryConfiguration dnsServiceDiscovery() {
- DnsServiceCallServiceDiscoveryConfiguration conf = new DnsServiceCallServiceDiscoveryConfiguration();
- addServiceDiscoveryConfigurations(conf);
-
- return conf;
- }
-
- public EtcdServiceCallServiceDiscoveryConfiguration etcdServiceDiscovery() {
- EtcdServiceCallServiceDiscoveryConfiguration conf = new EtcdServiceCallServiceDiscoveryConfiguration();
- addServiceDiscoveryConfigurations(conf);
-
- return conf;
- }
-
- public KubernetesServiceCallServiceDiscoveryConfiguration kubernetesServiceDiscovery() {
- KubernetesServiceCallServiceDiscoveryConfiguration conf = new KubernetesServiceCallServiceDiscoveryConfiguration();
- addServiceDiscoveryConfigurations(conf);
-
- return conf;
- }
-
- public ChainedServiceCallServiceDiscoveryConfiguration multiServiceDiscovery() {
- ChainedServiceCallServiceDiscoveryConfiguration conf = new ChainedServiceCallServiceDiscoveryConfiguration();
- addServiceDiscoveryConfigurations(conf);
-
- return conf;
- }
-
- public StaticServiceCallServiceDiscoveryConfiguration staticServiceDiscovery() {
- StaticServiceCallServiceDiscoveryConfiguration conf = new StaticServiceCallServiceDiscoveryConfiguration();
- addServiceDiscoveryConfigurations(conf);
-
- return conf;
- }
-
- // *************************************************************************
- // Utilities
- // *************************************************************************
-
- @Override
- protected void postProcessFactoryParameters(final CamelContext camelContext, final Map<String, Object> parameters) throws Exception {
- if (serviceDiscoveryConfigurations != null && !serviceDiscoveryConfigurations.isEmpty()) {
- List<ServiceDiscovery> discoveries = new ArrayList<>(serviceDiscoveryConfigurations.size());
- for (ServiceCallServiceDiscoveryConfiguration conf : serviceDiscoveryConfigurations) {
- discoveries.add(conf.newInstance(camelContext));
- }
-
- parameters.put("serviceDiscoveryList", discoveries);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/daca8394/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 005682a..aa0be7d 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
@@ -69,7 +69,7 @@ public class ServiceCallConfigurationDefinition extends IdentifiedType {
private Expression expression;
@XmlElements({
@XmlElement(name = "cachingServiceDiscovery", type = CachingServiceCallServiceDiscoveryConfiguration.class),
- @XmlElement(name = "chainedServiceDiscovery", type = ChainedServiceCallServiceDiscoveryConfiguration.class),
+ @XmlElement(name = "aggregatingServiceDiscovery", type = AggregatingServiceCallServiceDiscoveryConfiguration.class),
@XmlElement(name = "consulServiceDiscovery", type = ConsulServiceCallServiceDiscoveryConfiguration.class),
@XmlElement(name = "dnsServiceDiscovery", type = DnsServiceCallServiceDiscoveryConfiguration.class),
@XmlElement(name = "etcdServiceDiscovery", type = EtcdServiceCallServiceDiscoveryConfiguration.class),
@@ -539,14 +539,14 @@ public class ServiceCallConfigurationDefinition extends IdentifiedType {
return this;
}
- public ChainedServiceCallServiceDiscoveryConfiguration multiServiceDiscovery() {
- ChainedServiceCallServiceDiscoveryConfiguration conf = new ChainedServiceCallServiceDiscoveryConfiguration();
+ public AggregatingServiceCallServiceDiscoveryConfiguration multiServiceDiscovery() {
+ AggregatingServiceCallServiceDiscoveryConfiguration conf = new AggregatingServiceCallServiceDiscoveryConfiguration();
setServiceDiscoveryConfiguration(conf);
return conf;
}
- public ServiceCallConfigurationDefinition multiServiceDiscovery(ChainedServiceCallServiceDiscoveryConfiguration conf) {
+ public ServiceCallConfigurationDefinition multiServiceDiscovery(AggregatingServiceCallServiceDiscoveryConfiguration conf) {
setServiceDiscoveryConfiguration(conf);
return this;
http://git-wip-us.apache.org/repos/asf/camel/blob/daca8394/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 448faf5..4b3ac75 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
@@ -95,7 +95,7 @@ public class ServiceCallDefinition extends NoOutputDefinition<ServiceCallDefinit
@XmlElements({
@XmlElement(name = "cachingServiceDiscovery", type = CachingServiceCallServiceDiscoveryConfiguration.class),
- @XmlElement(name = "chainedServiceDiscovery", type = ChainedServiceCallServiceDiscoveryConfiguration.class),
+ @XmlElement(name = "aggregatingServiceDiscovery", type = AggregatingServiceCallServiceDiscoveryConfiguration.class),
@XmlElement(name = "consulServiceDiscovery", type = ConsulServiceCallServiceDiscoveryConfiguration.class),
@XmlElement(name = "dnsServiceDiscovery", type = DnsServiceCallServiceDiscoveryConfiguration.class),
@XmlElement(name = "etcdServiceDiscovery", type = EtcdServiceCallServiceDiscoveryConfiguration.class),
@@ -637,8 +637,8 @@ public class ServiceCallDefinition extends NoOutputDefinition<ServiceCallDefinit
return this;
}
- public ChainedServiceCallServiceDiscoveryConfiguration multiServiceDiscovery() {
- ChainedServiceCallServiceDiscoveryConfiguration conf = new ChainedServiceCallServiceDiscoveryConfiguration(this);
+ public AggregatingServiceCallServiceDiscoveryConfiguration multiServiceDiscovery() {
+ AggregatingServiceCallServiceDiscoveryConfiguration conf = new AggregatingServiceCallServiceDiscoveryConfiguration(this);
setServiceDiscoveryConfiguration(conf);
return conf;
http://git-wip-us.apache.org/repos/asf/camel/blob/daca8394/camel-core/src/main/resources/META-INF/services/org/apache/camel/cloud/aggregating-service-discovery
----------------------------------------------------------------------
diff --git a/camel-core/src/main/resources/META-INF/services/org/apache/camel/cloud/aggregating-service-discovery b/camel-core/src/main/resources/META-INF/services/org/apache/camel/cloud/aggregating-service-discovery
new file mode 100644
index 0000000..675af88
--- /dev/null
+++ b/camel-core/src/main/resources/META-INF/services/org/apache/camel/cloud/aggregating-service-discovery
@@ -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.AggregatingServiceDiscoveryFactory
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/daca8394/camel-core/src/main/resources/META-INF/services/org/apache/camel/cloud/chained-service-discovery
----------------------------------------------------------------------
diff --git a/camel-core/src/main/resources/META-INF/services/org/apache/camel/cloud/chained-service-discovery b/camel-core/src/main/resources/META-INF/services/org/apache/camel/cloud/chained-service-discovery
deleted file mode 100644
index e183367..0000000
--- a/camel-core/src/main/resources/META-INF/services/org/apache/camel/cloud/chained-service-discovery
+++ /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.ChainedServiceDiscoveryFactory
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/daca8394/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 7d5156b..5f5af59 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
@@ -29,6 +29,6 @@ DnsServiceCallServiceDiscoveryConfiguration
EtcdServiceCallServiceDiscoveryConfiguration
HealthyServiceCallServiceFilterConfiguration
KubernetesServiceCallServiceDiscoveryConfiguration
-ChainedServiceCallServiceDiscoveryConfiguration
+AggregatingServiceCallServiceDiscoveryConfiguration
StaticServiceCallServiceDiscoveryConfiguration
RibbonServiceCallLoadBalancerConfiguration
http://git-wip-us.apache.org/repos/asf/camel/blob/daca8394/camel-core/src/test/java/org/apache/camel/impl/cloud/AggregatingServiceDiscoveryTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/cloud/AggregatingServiceDiscoveryTest.java b/camel-core/src/test/java/org/apache/camel/impl/cloud/AggregatingServiceDiscoveryTest.java
new file mode 100644
index 0000000..76a5a59
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/impl/cloud/AggregatingServiceDiscoveryTest.java
@@ -0,0 +1,71 @@
+/**
+ * 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.Arrays;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.model.cloud.AggregatingServiceCallServiceDiscoveryConfiguration;
+import org.apache.camel.model.cloud.StaticServiceCallServiceDiscoveryConfiguration;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class AggregatingServiceDiscoveryTest extends ContextTestSupport {
+ @Test
+ public void testMultiServiceDiscovery() throws Exception {
+ StaticServiceDiscovery discovery1 = new StaticServiceDiscovery();
+ discovery1.addServer(new DefaultServiceDefinition("discovery1", "localhost", 1111));
+ discovery1.addServer(new DefaultServiceDefinition("discovery1", "localhost", 1112));
+
+ StaticServiceDiscovery discovery2 = new StaticServiceDiscovery();
+ discovery2.addServer(new DefaultServiceDefinition("discovery1", "localhost", 1113));
+ discovery2.addServer(new DefaultServiceDefinition("discovery2", "localhost", 1114));
+
+ AggregatingServiceDiscovery discovery = AggregatingServiceDiscovery.wrap(discovery1, discovery2);
+ Assert.assertEquals(3, discovery.getServices("discovery1").size());
+ Assert.assertEquals(1, discovery.getServices("discovery2").size());
+ }
+
+ @Test
+ public void testMultiServiceDiscoveryConfiguration() throws Exception {
+ StaticServiceCallServiceDiscoveryConfiguration staticConf1 = new StaticServiceCallServiceDiscoveryConfiguration();
+ staticConf1.setServers(Arrays.asList("discovery1@localhost:1111", "discovery1@localhost:1112"));
+
+ StaticServiceCallServiceDiscoveryConfiguration staticConf2 = new StaticServiceCallServiceDiscoveryConfiguration();
+ staticConf2.setServers(Arrays.asList("discovery1@localhost:1113", "discovery2@localhost:1114"));
+
+ AggregatingServiceCallServiceDiscoveryConfiguration multiConf = new AggregatingServiceCallServiceDiscoveryConfiguration();
+ multiConf.setServiceDiscoveryConfigurations(Arrays.asList(staticConf1, staticConf2));
+
+ AggregatingServiceDiscovery discovery = (AggregatingServiceDiscovery)multiConf.newInstance(context);
+ Assert.assertEquals(2, discovery.getDelegates().size());
+ Assert.assertEquals(3, discovery.getServices("discovery1").size());
+ Assert.assertEquals(1, discovery.getServices("discovery2").size());
+ }
+
+ @Test
+ public void testMultiServiceDiscoveryConfigurationDsl() throws Exception {
+ AggregatingServiceCallServiceDiscoveryConfiguration multiConf = new AggregatingServiceCallServiceDiscoveryConfiguration();
+ multiConf.staticServiceDiscovery().setServers(Arrays.asList("discovery1@localhost:1111", "discovery1@localhost:1112"));
+ multiConf.staticServiceDiscovery().setServers(Arrays.asList("discovery1@localhost:1113", "discovery2@localhost:1114"));
+
+ AggregatingServiceDiscovery discovery = (AggregatingServiceDiscovery)multiConf.newInstance(context);
+ Assert.assertEquals(2, discovery.getDelegates().size());
+ Assert.assertEquals(3, discovery.getServices("discovery1").size());
+ Assert.assertEquals(1, discovery.getServices("discovery2").size());
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/daca8394/camel-core/src/test/java/org/apache/camel/impl/cloud/ChainedServiceDiscoveryTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/cloud/ChainedServiceDiscoveryTest.java b/camel-core/src/test/java/org/apache/camel/impl/cloud/ChainedServiceDiscoveryTest.java
deleted file mode 100644
index d04d56c..0000000
--- a/camel-core/src/test/java/org/apache/camel/impl/cloud/ChainedServiceDiscoveryTest.java
+++ /dev/null
@@ -1,71 +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.Arrays;
-
-import org.apache.camel.ContextTestSupport;
-import org.apache.camel.model.cloud.ChainedServiceCallServiceDiscoveryConfiguration;
-import org.apache.camel.model.cloud.StaticServiceCallServiceDiscoveryConfiguration;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class ChainedServiceDiscoveryTest extends ContextTestSupport {
- @Test
- public void testMultiServiceDiscovery() throws Exception {
- StaticServiceDiscovery discovery1 = new StaticServiceDiscovery();
- discovery1.addServer(new DefaultServiceDefinition("discovery1", "localhost", 1111));
- discovery1.addServer(new DefaultServiceDefinition("discovery1", "localhost", 1112));
-
- StaticServiceDiscovery discovery2 = new StaticServiceDiscovery();
- discovery2.addServer(new DefaultServiceDefinition("discovery1", "localhost", 1113));
- discovery2.addServer(new DefaultServiceDefinition("discovery2", "localhost", 1114));
-
- ChainedServiceDiscovery discovery = ChainedServiceDiscovery.wrap(discovery1, discovery2);
- Assert.assertEquals(3, discovery.getServices("discovery1").size());
- Assert.assertEquals(1, discovery.getServices("discovery2").size());
- }
-
- @Test
- public void testMultiServiceDiscoveryConfiguration() throws Exception {
- StaticServiceCallServiceDiscoveryConfiguration staticConf1 = new StaticServiceCallServiceDiscoveryConfiguration();
- staticConf1.setServers(Arrays.asList("discovery1@localhost:1111", "discovery1@localhost:1112"));
-
- StaticServiceCallServiceDiscoveryConfiguration staticConf2 = new StaticServiceCallServiceDiscoveryConfiguration();
- staticConf2.setServers(Arrays.asList("discovery1@localhost:1113", "discovery2@localhost:1114"));
-
- ChainedServiceCallServiceDiscoveryConfiguration multiConf = new ChainedServiceCallServiceDiscoveryConfiguration();
- multiConf.setServiceDiscoveryConfigurations(Arrays.asList(staticConf1, staticConf2));
-
- ChainedServiceDiscovery discovery = (ChainedServiceDiscovery)multiConf.newInstance(context);
- Assert.assertEquals(2, discovery.getDelegates().size());
- Assert.assertEquals(3, discovery.getServices("discovery1").size());
- Assert.assertEquals(1, discovery.getServices("discovery2").size());
- }
-
- @Test
- public void testMultiServiceDiscoveryConfigurationDsl() throws Exception {
- ChainedServiceCallServiceDiscoveryConfiguration multiConf = new ChainedServiceCallServiceDiscoveryConfiguration();
- multiConf.staticServiceDiscovery().setServers(Arrays.asList("discovery1@localhost:1111", "discovery1@localhost:1112"));
- multiConf.staticServiceDiscovery().setServers(Arrays.asList("discovery1@localhost:1113", "discovery2@localhost:1114"));
-
- ChainedServiceDiscovery discovery = (ChainedServiceDiscovery)multiConf.newInstance(context);
- Assert.assertEquals(2, discovery.getDelegates().size());
- Assert.assertEquals(3, discovery.getServices("discovery1").size());
- Assert.assertEquals(1, discovery.getServices("discovery2").size());
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/daca8394/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceDiscovery.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceDiscovery.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceDiscovery.java
index 6428b63..f0400e1 100644
--- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceDiscovery.java
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceDiscovery.java
@@ -21,8 +21,8 @@ import java.util.concurrent.TimeUnit;
import org.apache.camel.cloud.ServiceDefinition;
import org.apache.camel.cloud.ServiceDiscovery;
+import org.apache.camel.impl.cloud.AggregatingServiceDiscovery;
import org.apache.camel.impl.cloud.CachingServiceDiscovery;
-import org.apache.camel.impl.cloud.ChainedServiceDiscovery;
public class CamelCloudServiceDiscovery implements ServiceDiscovery {
private ServiceDiscovery delegate;
@@ -30,7 +30,7 @@ public class CamelCloudServiceDiscovery implements ServiceDiscovery {
public CamelCloudServiceDiscovery(Long timeout, List<ServiceDiscovery> serviceDiscoveryList) {
// Created a chained service discovery that collects services from multiple
// ServiceDiscovery
- this.delegate = new ChainedServiceDiscovery(serviceDiscoveryList);
+ this.delegate = new AggregatingServiceDiscovery(serviceDiscoveryList);
// If a timeout is provided, wrap the serviceDiscovery with a caching
// strategy so the discovery implementations are not queried for each
http://git-wip-us.apache.org/repos/asf/camel/blob/daca8394/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceDiscoveryAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceDiscoveryAutoConfiguration.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceDiscoveryAutoConfiguration.java
index 02b3c34..c374a93 100644
--- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceDiscoveryAutoConfiguration.java
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceDiscoveryAutoConfiguration.java
@@ -17,7 +17,6 @@
package org.apache.camel.spring.boot.cloud;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
@@ -26,9 +25,7 @@ import org.apache.camel.CamelContext;
import org.apache.camel.NoTypeConversionAvailableException;
import org.apache.camel.cloud.ServiceDiscovery;
import org.apache.camel.impl.cloud.StaticServiceDiscovery;
-import org.apache.camel.model.HystrixConfigurationDefinition;
import org.apache.camel.spring.boot.util.GroupCondition;
-import org.apache.camel.util.IntrospectionSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
@@ -91,12 +88,7 @@ public class CamelCloudServiceDiscoveryAutoConfiguration implements BeanFactoryA
final ConfigurableBeanFactory factory = (ConfigurableBeanFactory) beanFactory;
configurationProperties.getServiceDiscovery().getConfigurations().entrySet().stream()
- .forEach(
- entry -> factory.registerSingleton(
- entry.getKey(),
- createStaticServiceDiscovery(entry.getValue())
- )
- );
+ .forEach(entry -> registerBean(factory, entry.getKey(), entry.getValue()));
}
// *******************************
@@ -116,6 +108,13 @@ public class CamelCloudServiceDiscoveryAutoConfiguration implements BeanFactoryA
// Helper
// *******************************
+ private void registerBean(ConfigurableBeanFactory factory, String name, CamelCloudConfigurationProperties.ServiceDiscoveryConfiguration configuration) {
+ factory.registerSingleton(
+ name,
+ createStaticServiceDiscovery(configuration)
+ );
+ }
+
private ServiceDiscovery createStaticServiceDiscovery(CamelCloudConfigurationProperties.ServiceDiscoveryConfiguration configuration) {
StaticServiceDiscovery staticServiceDiscovery = new StaticServiceDiscovery();
http://git-wip-us.apache.org/repos/asf/camel/blob/daca8394/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceFilterAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceFilterAutoConfiguration.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceFilterAutoConfiguration.java
index eea3e6a..a0a33ed 100644
--- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceFilterAutoConfiguration.java
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceFilterAutoConfiguration.java
@@ -77,12 +77,7 @@ public class CamelCloudServiceFilterAutoConfiguration implements BeanFactoryAwar
final ConfigurableBeanFactory factory = (ConfigurableBeanFactory) beanFactory;
configurationProperties.getServiceFilter().getConfigurations().entrySet().stream()
- .forEach(
- entry -> factory.registerSingleton(
- entry.getKey(),
- createServiceFilter(entry.getValue())
- )
- );
+ .forEach(entry -> registerBean(factory, entry.getKey(), entry.getValue()));
}
// *******************************
@@ -102,6 +97,13 @@ public class CamelCloudServiceFilterAutoConfiguration implements BeanFactoryAwar
// Helper
// *******************************
+ private void registerBean(ConfigurableBeanFactory factory, String name, CamelCloudConfigurationProperties.ServiceFilterConfiguration configuration) {
+ factory.registerSingleton(
+ name,
+ createServiceFilter(configuration)
+ );
+ }
+
private CamelCloudServiceFilter createServiceFilter(CamelCloudConfigurationProperties.ServiceFilterConfiguration configuration) {
BlacklistServiceFilter blacklist = new BlacklistServiceFilter();
http://git-wip-us.apache.org/repos/asf/camel/blob/daca8394/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 be76730..d988a18 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
@@ -16,8 +16,8 @@
*/
package org.apache.camel.spring.cloud;
+import org.apache.camel.model.cloud.AggregatingServiceCallServiceDiscoveryConfiguration;
import org.apache.camel.model.cloud.BlacklistServiceCallServiceFilterConfiguration;
-import org.apache.camel.model.cloud.ChainedServiceCallServiceDiscoveryConfiguration;
import org.apache.camel.model.cloud.ChainedServiceCallServiceFilterConfiguration;
import org.apache.camel.model.cloud.DefaultServiceCallLoadBalancerConfiguration;
import org.apache.camel.model.cloud.HealthyServiceCallServiceFilterConfiguration;
@@ -52,7 +52,7 @@ public class ServiceCallConfigurationTest {
assertNotNull("No ServiceDiscoveryConfiguration (2)", conf2.getServiceDiscoveryConfiguration());
assertNull(conf2.getLoadBalancerConfiguration());
- ChainedServiceCallServiceDiscoveryConfiguration discovery2 = (ChainedServiceCallServiceDiscoveryConfiguration)conf2.getServiceDiscoveryConfiguration();
+ AggregatingServiceCallServiceDiscoveryConfiguration discovery2 = (AggregatingServiceCallServiceDiscoveryConfiguration)conf2.getServiceDiscoveryConfiguration();
assertEquals(2, discovery2.getServiceDiscoveryConfigurations().size());
assertTrue(discovery2.getServiceDiscoveryConfigurations().get(0) instanceof StaticServiceCallServiceDiscoveryConfiguration);
assertTrue(discovery2.getServiceDiscoveryConfigurations().get(1) instanceof StaticServiceCallServiceDiscoveryConfiguration);
http://git-wip-us.apache.org/repos/asf/camel/blob/daca8394/components/camel-spring/src/test/resources/org/apache/camel/spring/cloud/ServiceCallConfigurationTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/cloud/ServiceCallConfigurationTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/cloud/ServiceCallConfigurationTest.xml
index 70ed090..c6851c8 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/cloud/ServiceCallConfigurationTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/cloud/ServiceCallConfigurationTest.xml
@@ -33,14 +33,14 @@
</serviceCallConfiguration>
<serviceCallConfiguration id="conf2">
- <chainedServiceDiscovery>
+ <aggregatingServiceDiscovery>
<staticServiceDiscovery>
<servers>localhost:9092</servers>
</staticServiceDiscovery>
<staticServiceDiscovery>
<servers>localhost:9093,localhost:9094,localhost:9095,localhost:9096</servers>
</staticServiceDiscovery>
- </chainedServiceDiscovery>
+ </aggregatingServiceDiscovery>
<chainedServiceFilter>
<healthyServiceFilter/>
<blacklistServiceFilter>