camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject git commit: CAMEL-7364: Rest DSL polished
Date Mon, 21 Jul 2014 12:24:21 GMT
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 <davsclaus@apache.org>
Authored: Mon Jul 21 14:24:01 2014 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
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 @@
+<!--
+    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.
+-->
+<html>
+<head>
+</head>
+<body>
+
+The <a href="http://camel.apache.org/rest.html">REST Component</a> for defining
REST services, supporting
+the Camel <a href="http://camel.apache.org/rest-dsl">Rest DSL</a>.
+
+</body>
+</html>

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<String, Object> properties;
@@ -66,6 +67,24 @@ public class RestConfiguration {
     }
 
     /**
+     * Gets the scheme to use by the REST consumer
+     *
+     * @return the scheme, or <tt>null</tt> 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 <tt>0</tt> or <tt>-1</tt> 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);
 


Mime
View raw message