Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 71C3411C7D for ; Mon, 21 Jul 2014 12:24:26 +0000 (UTC) Received: (qmail 16126 invoked by uid 500); 21 Jul 2014 12:24:21 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 16052 invoked by uid 500); 21 Jul 2014 12:24:21 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 16008 invoked by uid 99); 21 Jul 2014 12:24:21 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Jul 2014 12:24:21 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 712D69A6F96; Mon, 21 Jul 2014 12:24:21 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davsclaus@apache.org To: commits@camel.apache.org Message-Id: <48370a60a2e647bc8347131cc59b2849@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: CAMEL-7364: Rest DSL polished Date: Mon, 21 Jul 2014 12:24:21 +0000 (UTC) Repository: camel Updated Branches: refs/heads/master 049923e28 -> 131f86d80 CAMEL-7364: Rest DSL polished Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/131f86d8 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/131f86d8 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/131f86d8 Branch: refs/heads/master Commit: 131f86d80a1a73b89f53bda19a40d5f3e1f7f7c8 Parents: 049923e Author: Claus Ibsen Authored: Mon Jul 21 14:24:01 2014 +0200 Committer: Claus Ibsen Committed: Mon Jul 21 14:24:01 2014 +0200 ---------------------------------------------------------------------- .../apache/camel/component/rest/package.html | 26 +++++++++++++++ .../model/rest/RestConfigurationDefinition.java | 34 ++++++++++++++++++++ .../org/apache/camel/spi/RestConfiguration.java | 19 +++++++++++ .../component/restlet/RestletComponent.java | 14 +++++--- 4 files changed, 88 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/131f86d8/camel-core/src/main/java/org/apache/camel/component/rest/package.html ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/rest/package.html b/camel-core/src/main/java/org/apache/camel/component/rest/package.html new file mode 100644 index 0000000..3955c55 --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/component/rest/package.html @@ -0,0 +1,26 @@ + + + + + + +The REST Component for defining REST services, supporting +the Camel Rest DSL. + + + http://git-wip-us.apache.org/repos/asf/camel/blob/131f86d8/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java index 797b06a..cac4225 100644 --- a/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java +++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java @@ -41,6 +41,9 @@ public class RestConfigurationDefinition { private String component; @XmlAttribute + private String scheme; + + @XmlAttribute private String host; @XmlAttribute @@ -57,6 +60,14 @@ public class RestConfigurationDefinition { this.component = component; } + public String getScheme() { + return scheme; + } + + public void setScheme(String scheme) { + this.scheme = scheme; + } + public String getHost() { return host; } @@ -92,21 +103,41 @@ public class RestConfigurationDefinition { return this; } + /** + * To use a specific scheme such as http/https + */ + public RestConfigurationDefinition scheme(String scheme) { + setScheme(scheme); + return this; + } + + /** + * To define the host to use, such as 0.0.0.0 or localhost + */ public RestConfigurationDefinition host(String host) { setHost(host); return this; } + /** + * To specify the port number to use for the REST service + */ public RestConfigurationDefinition port(int port) { setPort("" + port); return this; } + /** + * To specify the port number to use for the REST service + */ public RestConfigurationDefinition port(String port) { setPort(port); return this; } + /** + * For additional configuration options + */ public RestConfigurationDefinition property(String key, String value) { RestPropertyDefinition prop = new RestPropertyDefinition(); prop.setKey(key); @@ -130,6 +161,9 @@ public class RestConfigurationDefinition { if (component != null) { answer.setComponent(CamelContextHelper.parseText(context, component)); } + if (scheme != null) { + answer.setScheme(CamelContextHelper.parseText(context, scheme)); + } if (host != null) { answer.setHost(CamelContextHelper.parseText(context, host)); } http://git-wip-us.apache.org/repos/asf/camel/blob/131f86d8/camel-core/src/main/java/org/apache/camel/spi/RestConfiguration.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/spi/RestConfiguration.java b/camel-core/src/main/java/org/apache/camel/spi/RestConfiguration.java index ab796b2..0152464 100644 --- a/camel-core/src/main/java/org/apache/camel/spi/RestConfiguration.java +++ b/camel-core/src/main/java/org/apache/camel/spi/RestConfiguration.java @@ -25,6 +25,7 @@ import java.util.Map; public class RestConfiguration { private String component; + private String scheme; private String host; private int port; private Map properties; @@ -66,6 +67,24 @@ public class RestConfiguration { } /** + * Gets the scheme to use by the REST consumer + * + * @return the scheme, or null to use default scheme + */ + public String getScheme() { + return scheme; + } + + /** + * Sets the scheme to use by the REST consumer + * + * @param scheme the scheme + */ + public void setScheme(String scheme) { + this.scheme = scheme; + } + + /** * Gets the port to use by the REST consumer * * @return the port, or 0 or -1 to use default port http://git-wip-us.apache.org/repos/asf/camel/blob/131f86d8/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java index 176032c..3c476c1 100644 --- a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java +++ b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java @@ -475,23 +475,27 @@ public class RestletComponent extends HeaderFilterStrategyComponent implements R path = FileUtil.stripLeadingSeparator(path); - int port = 0; + String scheme = "http"; String host = "0.0.0.0"; + int port = 0; // if no explicit port/host configured, then use port from rest configuration RestConfiguration config = getCamelContext().getRestConfiguration(); if (config != null && (config.getComponent() == null || config.getComponent().equals("restlet"))) { - int num = config.getPort(); - if (num > 0) { - port = num; + if (config.getScheme() != null) { + scheme = config.getScheme(); } if (config.getHost() != null) { host = config.getHost(); } + int num = config.getPort(); + if (num > 0) { + port = num; + } } // get the endpoint - String url = String.format("restlet:http://%s:%s/%s?restletMethod=%s", host, port, path, verb); + String url = String.format("restlet:%s://%s:%s/%s?restletMethod=%s", scheme, host, port, path, verb); RestletEndpoint endpoint = camelContext.getEndpoint(url, RestletEndpoint.class); setProperties(endpoint, parameters);