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/25 22:35:29 UTC
[1/2] camel git commit: Fix service-call global configuration
Repository: camel
Updated Branches:
refs/heads/master 2e839f0c9 -> afca0b700
Fix service-call global configuration
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6db3f45d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6db3f45d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6db3f45d
Branch: refs/heads/master
Commit: 6db3f45d2354fd8bb2fc591ad740e28f4647677f
Parents: 2e839f0
Author: lburgazzoli <lb...@gmail.com>
Authored: Sat Mar 25 22:58:39 2017 +0100
Committer: lburgazzoli <lb...@gmail.com>
Committed: Sat Mar 25 22:58:39 2017 +0100
----------------------------------------------------------------------
.../model/cloud/ServiceCallDefinition.java | 30 +++++++++++++++-----
components/camel-spring-boot/pom.xml | 3 +-
.../CamelCloudServiceCallExpressionTest.java | 8 +++---
...CloudServiceCallGlobalConfigurationTest.java | 10 +++----
.../boot/cloud/CamelCloudServiceCallTest.java | 10 +++----
5 files changed, 38 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/6db3f45d/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 98a9bf7..448faf5 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
@@ -749,17 +749,33 @@ public class ServiceCallDefinition extends NoOutputDefinition<ServiceCallDefinit
// The component is used to configure the default scheme to use (eg camel component name).
// The component configured on EIP takes precedence vs configured on configuration.
- String scheme = this.component;
- if (scheme == null) {
+ String endpointScheme = this.component;
+ if (endpointScheme == null) {
ServiceCallConfigurationDefinition conf = retrieveConfig(camelContext);
if (conf != null) {
- scheme = conf.getComponent();
+ endpointScheme = conf.getComponent();
}
}
- if (scheme == null) {
+ if (endpointScheme == null) {
ServiceCallConfigurationDefinition conf = retrieveDefaultConfig(camelContext);
if (conf != null) {
- scheme = conf.getComponent();
+ endpointScheme = conf.getComponent();
+ }
+ }
+
+ // The uri is used to tweak the uri.
+ // The uri configured on EIP takes precedence vs configured on configuration.
+ String endpointUri = this.uri;
+ if (endpointUri == null) {
+ ServiceCallConfigurationDefinition conf = retrieveConfig(camelContext);
+ if (conf != null) {
+ endpointUri = conf.getUri();
+ }
+ }
+ if (endpointUri == null) {
+ ServiceCallConfigurationDefinition conf = retrieveDefaultConfig(camelContext);
+ if (conf != null) {
+ endpointUri = conf.getUri();
}
}
@@ -769,8 +785,8 @@ public class ServiceCallDefinition extends NoOutputDefinition<ServiceCallDefinit
return new DefaultServiceCallProcessor(
camelContext,
camelContext.resolvePropertyPlaceholders(name),
- ObjectHelper.applyIfNotEmpty(scheme, camelContext::resolvePropertyPlaceholders, () -> ServiceCallConstants.DEFAULT_COMPONENT),
- ObjectHelper.applyIfNotEmpty(uri, camelContext::resolvePropertyPlaceholders, () -> null),
+ ObjectHelper.applyIfNotEmpty(endpointScheme, camelContext::resolvePropertyPlaceholders, () -> ServiceCallConstants.DEFAULT_COMPONENT),
+ ObjectHelper.applyIfNotEmpty(endpointUri, camelContext::resolvePropertyPlaceholders, () -> null),
pattern,
loadBalancer,
expression);
http://git-wip-us.apache.org/repos/asf/camel/blob/6db3f45d/components/camel-spring-boot/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/pom.xml b/components/camel-spring-boot/pom.xml
index f17f90f..f2cf091 100644
--- a/components/camel-spring-boot/pom.xml
+++ b/components/camel-spring-boot/pom.xml
@@ -72,7 +72,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<optional>true</optional>
- <version>${spring-boot-version}</version>
</dependency>
<!-- Testing dependencies -->
@@ -104,7 +103,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-netty4-http</artifactId>
+ <artifactId>camel-jetty</artifactId>
<scope>test</scope>
</dependency>
http://git-wip-us.apache.org/repos/asf/camel/blob/6db3f45d/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallExpressionTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallExpressionTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallExpressionTest.java
index 24a533a..ce4c037 100644
--- a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallExpressionTest.java
+++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallExpressionTest.java
@@ -41,7 +41,7 @@ import org.springframework.test.context.junit4.SpringRunner;
properties = {
"service.name=custom-svc-list",
"camel.cloud.load-balancer.enabled=false",
- "camel.cloud.service-call.component=netty4-http",
+ "camel.cloud.service-call.component=jetty",
"camel.cloud.service-call.expression=${header.CamelServiceCallScheme}:http://${header.CamelServiceCallServiceHost}:${header.CamelServiceCallServicePort}/hello",
"camel.cloud.service-discovery.services[custom-svc-list]=localhost:9090,localhost:9091,localhost:9092",
"camel.cloud.service-filter.blacklist[custom-svc-list]=localhost:9091",
@@ -73,13 +73,13 @@ public class CamelCloudServiceCallExpressionTest {
from("direct:start")
.serviceCall("{{service.name}}");
- from("netty4-http:http://localhost:9090/hello")
+ from("jetty:http://localhost:9090/hello")
.transform()
.constant("9090");
- from("netty4-http:http://localhost:9091/hello")
+ from("jetty:http://localhost:9091/hello")
.transform()
.constant("9091");
- from("netty4-http:http://localhost:9092/hello")
+ from("jetty:http://localhost:9092/hello")
.transform()
.constant("9092");
}
http://git-wip-us.apache.org/repos/asf/camel/blob/6db3f45d/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallGlobalConfigurationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallGlobalConfigurationTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallGlobalConfigurationTest.java
index aef1ca8..e8b08cb 100644
--- a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallGlobalConfigurationTest.java
+++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallGlobalConfigurationTest.java
@@ -41,7 +41,7 @@ import org.springframework.test.context.junit4.SpringRunner;
properties = {
"service.name=custom-svc-list",
"camel.cloud.load-balancer.enabled=false",
- "camel.cloud.service-call.uri=netty4-http:http://${service.name}",
+ "camel.cloud.service-call.uri=jetty:http://${service.name}/hello",
"camel.cloud.service-call.service-discovery=sd",
"camel.cloud.service-call.service-filter=sf",
// this should not be taken into account
@@ -78,15 +78,15 @@ public class CamelCloudServiceCallGlobalConfigurationTest {
@Override
public void configure() throws Exception {
from("direct:start")
- .serviceCall("{{service.name}}/hello");
+ .serviceCall("{{service.name}}");
- from("netty4-http:http://localhost:9090/hello")
+ from("jetty:http://localhost:9090/hello")
.transform()
.constant("9090");
- from("netty4-http:http://localhost:9091/hello")
+ from("jetty:http://localhost:9091/hello")
.transform()
.constant("9091");
- from("netty4-http:http://localhost:9092/hello")
+ from("jetty:http://localhost:9092/hello")
.transform()
.constant("9092");
}
http://git-wip-us.apache.org/repos/asf/camel/blob/6db3f45d/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallTest.java
index 216c37a..1409244 100644
--- a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallTest.java
+++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallTest.java
@@ -69,16 +69,16 @@ public class CamelCloudServiceCallTest {
public void configure() throws Exception {
from("direct:start")
.serviceCall()
- .name("custom-svc-list/hello")
- .uri("netty4-http:http://custom-svc-list");
+ .name("custom-svc-list")
+ .uri("jetty:http://custom-svc-list/hello");
- from("netty4-http:http://localhost:9090/hello")
+ from("jetty:http://localhost:9090/hello")
.transform()
.constant("9090");
- from("netty4-http:http://localhost:9091/hello")
+ from("jetty:http://localhost:9091/hello")
.transform()
.constant("9091");
- from("netty4-http:http://localhost:9092/hello")
+ from("jetty:http://localhost:9092/hello")
.transform()
.constant("9092");
}
[2/2] camel git commit: Make camel-http4 the default for service-call
as camel-http has been deprecated
Posted by lb...@apache.org.
Make camel-http4 the default for service-call as camel-http has been deprecated
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/afca0b70
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/afca0b70
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/afca0b70
Branch: refs/heads/master
Commit: afca0b7002f3ea734c823e8c6bd2eb7a455a7795
Parents: 6db3f45
Author: lburgazzoli <lb...@gmail.com>
Authored: Sat Mar 25 23:35:02 2017 +0100
Committer: lburgazzoli <lb...@gmail.com>
Committed: Sat Mar 25 23:35:02 2017 +0100
----------------------------------------------------------------------
.../impl/cloud/DefaultServiceCallExpression.java | 14 +++++++-------
.../camel/model/cloud/ServiceCallConstants.java | 2 +-
components/camel-consul/pom.xml | 2 +-
components/camel-etcd/pom.xml | 2 +-
components/camel-kubernetes/pom.xml | 2 +-
components/camel-ribbon/pom.xml | 2 +-
.../CamelCloudServiceDiscoveryAutoConfiguration.java | 2 ++
.../CamelCloudServiceFilterAutoConfiguration.java | 2 ++
components/camel-spring-cloud-netflix/pom.xml | 2 +-
components/camel-spring-cloud/pom.xml | 2 +-
10 files changed, 18 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/afca0b70/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultServiceCallExpression.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultServiceCallExpression.java b/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultServiceCallExpression.java
index 1279baf..e1c49f7 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultServiceCallExpression.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/cloud/DefaultServiceCallExpression.java
@@ -26,10 +26,10 @@ import org.slf4j.LoggerFactory;
* <p/>
* Below are some examples how to call a service and what Camel endpoint URI is constructed based on the input:
* <pre>
- serviceCall("myService") -> http://hostname:port
- serviceCall("myService/foo") -> http://hostname:port/foo
- serviceCall("http:myService/foo") -> http:hostname:port/foo
- serviceCall("myService", "http:myService.host:myService.port/foo") -> http:hostname:port/foo
+ serviceCall("myService") -> http4://hostname:port
+ serviceCall("myService/foo") -> http4://hostname:port/foo
+ serviceCall("http4:myService/foo") -> http4:hostname:port/foo
+ serviceCall("myService", "http4:myService.host:myService.port/foo") -> http4:hostname:port/foo
serviceCall("myService", "netty4:tcp:myService?connectTimeout=1000") -> netty:tcp:hostname:port?connectTimeout=1000
* </pre>
*/
@@ -44,11 +44,11 @@ public class DefaultServiceCallExpression extends ServiceCallExpressionSupport {
if (scheme == null) {
// use http/https by default if no scheme or port have been configured
if (port == null) {
- scheme = "http";
+ scheme = "http4";
} else if (port == 443) {
- scheme = "https";
+ scheme = "https4";
} else {
- scheme = "http";
+ scheme = "http4";
}
}
answer = scheme + "://" + host;
http://git-wip-us.apache.org/repos/asf/camel/blob/afca0b70/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallConstants.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallConstants.java b/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallConstants.java
index 4cc89f1..8859f33 100644
--- a/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallConstants.java
+++ b/camel-core/src/main/java/org/apache/camel/model/cloud/ServiceCallConstants.java
@@ -17,7 +17,7 @@
package org.apache.camel.model.cloud;
public final class ServiceCallConstants {
- public static final String DEFAULT_COMPONENT = "http";
+ public static final String DEFAULT_COMPONENT = "http4";
public static final String DEFAULT_SERVICE_CALL_CONFIG_ID = "service-call-configuration";
public static final String DEFAULT_SERVICE_CALL_EXPRESSION_ID = "service-call-expression";
public static final String DEFAULT_SERVICE_DISCOVERY_ID = "service-discovery";
http://git-wip-us.apache.org/repos/asf/camel/blob/afca0b70/components/camel-consul/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-consul/pom.xml b/components/camel-consul/pom.xml
index 133d2ff..dd1a4d3 100644
--- a/components/camel-consul/pom.xml
+++ b/components/camel-consul/pom.xml
@@ -64,7 +64,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-http</artifactId>
+ <artifactId>camel-http4</artifactId>
<scope>test</scope>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/camel/blob/afca0b70/components/camel-etcd/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-etcd/pom.xml b/components/camel-etcd/pom.xml
index cec4db5..9136f98 100644
--- a/components/camel-etcd/pom.xml
+++ b/components/camel-etcd/pom.xml
@@ -88,7 +88,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-http</artifactId>
+ <artifactId>camel-http4</artifactId>
<scope>test</scope>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/camel/blob/afca0b70/components/camel-kubernetes/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-kubernetes/pom.xml b/components/camel-kubernetes/pom.xml
index 2be203e..ad97c42 100644
--- a/components/camel-kubernetes/pom.xml
+++ b/components/camel-kubernetes/pom.xml
@@ -57,7 +57,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-http</artifactId>
+ <artifactId>camel-http4</artifactId>
<scope>test</scope>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/camel/blob/afca0b70/components/camel-ribbon/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-ribbon/pom.xml b/components/camel-ribbon/pom.xml
index 3786e37..7ad8c5e 100644
--- a/components/camel-ribbon/pom.xml
+++ b/components/camel-ribbon/pom.xml
@@ -65,7 +65,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-http</artifactId>
+ <artifactId>camel-http4</artifactId>
<scope>test</scope>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/camel/blob/afca0b70/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 06ef3d7..02b3c34 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
@@ -36,6 +36,7 @@ import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
@@ -43,6 +44,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
@Configuration
+@ConditionalOnBean(CamelCloudAutoConfiguration.class)
@EnableConfigurationProperties(CamelCloudConfigurationProperties.class)
@Conditional(CamelCloudServiceDiscoveryAutoConfiguration.Condition.class)
public class CamelCloudServiceDiscoveryAutoConfiguration implements BeanFactoryAware {
http://git-wip-us.apache.org/repos/asf/camel/blob/afca0b70/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 f3b7866..eea3e6a 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
@@ -35,6 +35,7 @@ import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
@@ -42,6 +43,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
@Configuration
+@ConditionalOnBean(CamelCloudAutoConfiguration.class)
@EnableConfigurationProperties(CamelCloudConfigurationProperties.class)
@Conditional(CamelCloudServiceFilterAutoConfiguration.Condition.class)
public class CamelCloudServiceFilterAutoConfiguration implements BeanFactoryAware {
http://git-wip-us.apache.org/repos/asf/camel/blob/afca0b70/components/camel-spring-cloud-netflix/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring-cloud-netflix/pom.xml b/components/camel-spring-cloud-netflix/pom.xml
index 5d6ca11..0b1d31f 100644
--- a/components/camel-spring-cloud-netflix/pom.xml
+++ b/components/camel-spring-cloud-netflix/pom.xml
@@ -77,7 +77,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-http</artifactId>
+ <artifactId>camel-http4</artifactId>
<scope>test</scope>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/camel/blob/afca0b70/components/camel-spring-cloud/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring-cloud/pom.xml b/components/camel-spring-cloud/pom.xml
index c57bcff..0b96b57 100644
--- a/components/camel-spring-cloud/pom.xml
+++ b/components/camel-spring-cloud/pom.xml
@@ -73,7 +73,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-http</artifactId>
+ <artifactId>camel-http4</artifactId>
<scope>test</scope>
</dependency>
<dependency>