You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/05/23 08:05:20 UTC
[33/34] camel git commit: CAMEL-9683: Made configuration of service
call easier
CAMEL-9683: Made configuration of service call easier
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1177115e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1177115e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1177115e
Branch: refs/heads/remoteServiceCall
Commit: 1177115ebd56bcb8ccc59e238361d3e6a38f9e06
Parents: 0cdb878
Author: Claus Ibsen <da...@apache.org>
Authored: Thu May 19 14:13:53 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon May 23 09:28:28 2016 +0200
----------------------------------------------------------------------
.../ServiceCallConfigurationDefinition.java | 18 ------------------
.../camel/model/remote/ServiceCallDefinition.java | 13 +------------
.../processor/KubernetesProcessorFactory.java | 18 ++++--------------
.../ribbon/processor/RibbonProcessorFactory.java | 18 ++++--------------
4 files changed, 9 insertions(+), 58 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/1177115e/camel-core/src/main/java/org/apache/camel/model/remote/ServiceCallConfigurationDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/remote/ServiceCallConfigurationDefinition.java b/camel-core/src/main/java/org/apache/camel/model/remote/ServiceCallConfigurationDefinition.java
index 4b51bd7..526a0d3 100644
--- a/camel-core/src/main/java/org/apache/camel/model/remote/ServiceCallConfigurationDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/remote/ServiceCallConfigurationDefinition.java
@@ -47,8 +47,6 @@ public abstract class ServiceCallConfigurationDefinition extends IdentifiedType
@XmlTransient
private ServiceCallDefinition parent;
@XmlAttribute
- private String component;
- @XmlAttribute
private String loadBalancerRef;
@XmlTransient
private ServiceCallLoadBalancer loadBalancer;
@@ -72,14 +70,6 @@ public abstract class ServiceCallConfigurationDefinition extends IdentifiedType
// Getter/Setter
// -------------------------------------------------------------------------
- public String getComponent() {
- return component;
- }
-
- public void setComponent(String component) {
- this.component = component;
- }
-
public String getLoadBalancerRef() {
return loadBalancerRef;
}
@@ -134,14 +124,6 @@ public abstract class ServiceCallConfigurationDefinition extends IdentifiedType
// -------------------------------------------------------------------------
/**
- * Sets the name of the Camel component to use such as ribbon or kubernetes
- */
- public ServiceCallConfigurationDefinition component(String component) {
- setComponent(component);
- return this;
- }
-
- /**
* Sets a reference to a custom {@link org.apache.camel.spi.ServiceCallLoadBalancer} to use.
*/
public ServiceCallConfigurationDefinition loadBalancer(String loadBalancerRef) {
http://git-wip-us.apache.org/repos/asf/camel/blob/1177115e/camel-core/src/main/java/org/apache/camel/model/remote/ServiceCallDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/remote/ServiceCallDefinition.java b/camel-core/src/main/java/org/apache/camel/model/remote/ServiceCallDefinition.java
index f12ce74..25ead8d 100644
--- a/camel-core/src/main/java/org/apache/camel/model/remote/ServiceCallDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/remote/ServiceCallDefinition.java
@@ -30,7 +30,6 @@ import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.RouteContext;
import org.apache.camel.spi.ServiceCallLoadBalancer;
import org.apache.camel.spi.ServiceCallServerListStrategy;
-import org.apache.camel.util.CamelContextHelper;
/**
* Remote service call
@@ -75,17 +74,7 @@ public class ServiceCallDefinition extends NoOutputDefinition<ServiceCallDefinit
@Override
public Processor createProcessor(RouteContext routeContext) throws Exception {
- String component = serviceCallConfiguration != null ? serviceCallConfiguration.getComponent() : null;
- if (component == null && serviceCallConfigurationRef != null) {
- ServiceCallConfigurationDefinition config = CamelContextHelper.mandatoryLookup(routeContext.getCamelContext(), serviceCallConfigurationRef, ServiceCallConfigurationDefinition.class);
- component = config.getComponent();
- }
-
- if (component != null) {
- throw new IllegalStateException("Cannot find Camel component on the classpath implementing the discovery provider: " + component);
- } else {
- throw new IllegalStateException("Cannot find Camel component supporting the ServiceCall EIP such as camel-kubernetes or camel-ribbon.");
- }
+ throw new IllegalStateException("Cannot find Camel component supporting the ServiceCall EIP such as camel-kubernetes or camel-ribbon.");
}
// Fluent API
http://git-wip-us.apache.org/repos/asf/camel/blob/1177115e/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/processor/KubernetesProcessorFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/processor/KubernetesProcessorFactory.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/processor/KubernetesProcessorFactory.java
index 3a1352e..73d9a07 100644
--- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/processor/KubernetesProcessorFactory.java
+++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/processor/KubernetesProcessorFactory.java
@@ -73,23 +73,13 @@ public class KubernetesProcessorFactory implements ProcessorFactory {
if (config == null) {
// if no default then try to find if there configuration in the registry of the given type
Set<KubernetesConfigurationDefinition> set = routeContext.getCamelContext().getRegistry().findByType(KubernetesConfigurationDefinition.class);
- if (set != null) {
- for (KubernetesConfigurationDefinition candidate : set) {
- if (candidate.getComponent() == null || "kubernetes".equals(candidate.getComponent())) {
- config = candidate;
- break;
- }
- }
+ if (set.size() == 1) {
+ config = set.iterator().next();
}
}
- // component must either not be set, or if set then must be us
- String component = config != null ? config.getComponent() : null;
- if (component == null && configRef != null) {
- component = configRef.getComponent();
- }
- if (component != null && !"kubernetes".equals(component)) {
- return null;
+ if (config == null && configRef == null) {
+ throw new IllegalStateException("The ServiceCall: " + definition + " must be configured before it can be used.");
}
// extract the properties from the configuration from the model
http://git-wip-us.apache.org/repos/asf/camel/blob/1177115e/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/processor/RibbonProcessorFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/processor/RibbonProcessorFactory.java b/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/processor/RibbonProcessorFactory.java
index e0821cf..f77557e 100644
--- a/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/processor/RibbonProcessorFactory.java
+++ b/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/processor/RibbonProcessorFactory.java
@@ -74,23 +74,13 @@ public class RibbonProcessorFactory implements ProcessorFactory {
if (config == null) {
// if no default then try to find if there configuration in the registry of the given type
Set<RibbonConfigurationDefinition> set = routeContext.getCamelContext().getRegistry().findByType(RibbonConfigurationDefinition.class);
- if (set != null) {
- for (RibbonConfigurationDefinition candidate : set) {
- if (candidate.getComponent() == null || "ribbon".equals(candidate.getComponent())) {
- config = candidate;
- break;
- }
- }
+ if (set.size() == 1) {
+ config = set.iterator().next();
}
}
- // component must either not be set, or if set then must be us
- String component = config != null ? config.getComponent() : null;
- if (component == null && configRef != null) {
- component = configRef.getComponent();
- }
- if (component != null && !"ribbon".equals(component)) {
- return null;
+ if (config == null && configRef == null) {
+ throw new IllegalStateException("The ServiceCall: " + definition + " must be configured before it can be used.");
}
// extract the properties from the configuration from the model