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 2017/08/07 08:22:16 UTC

[2/2] camel git commit: CAMEL-11636: rest-dsl should also use property placeholders on the verb and its params.

CAMEL-11636: rest-dsl should also use property placeholders on the verb and its params.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/507916f5
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/507916f5
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/507916f5

Branch: refs/heads/camel-2.19.x
Commit: 507916f525ecbd999bc2b45836abdc0acf553b8f
Parents: 0083911
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Aug 7 09:39:20 2017 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Aug 7 10:22:00 2017 +0200

----------------------------------------------------------------------
 .../apache/camel/model/rest/RestDefinition.java    | 11 +++++++++++
 .../src/main/resources/camel-config-xml.xml        |  6 +++++-
 .../src/main/resources/rest.properties             | 17 +++++++++++++++++
 3 files changed, 33 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/507916f5/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
index b668f48..fa024ae 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
@@ -32,6 +32,7 @@ import javax.xml.bind.annotation.XmlRootElement;
 import org.apache.camel.CamelContext;
 import org.apache.camel.model.OptionalIdentifiedDefinition;
 import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.ProcessorDefinitionHelper;
 import org.apache.camel.model.RouteDefinition;
 import org.apache.camel.model.ToDefinition;
 import org.apache.camel.model.ToDynamicDefinition;
@@ -723,6 +724,16 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition>
                 route.getOutputs().add(def);
             }
 
+            // ensure property placeholders is resolved on the verb
+            try {
+                ProcessorDefinitionHelper.resolvePropertyPlaceholders(camelContext, verb);
+                for (RestOperationParamDefinition param : verb.getParams()) {
+                    ProcessorDefinitionHelper.resolvePropertyPlaceholders(camelContext, param);
+                }
+            } catch (Exception e) {
+                throw ObjectHelper.wrapRuntimeCamelException(e);
+            }
+
             // add the binding
             RestBindingDefinition binding = new RestBindingDefinition();
             binding.setComponent(component);

http://git-wip-us.apache.org/repos/asf/camel/blob/507916f5/examples/camel-example-swagger-xml/src/main/resources/camel-config-xml.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-swagger-xml/src/main/resources/camel-config-xml.xml b/examples/camel-example-swagger-xml/src/main/resources/camel-config-xml.xml
index 45d4c0f..f037180 100755
--- a/examples/camel-example-swagger-xml/src/main/resources/camel-config-xml.xml
+++ b/examples/camel-example-swagger-xml/src/main/resources/camel-config-xml.xml
@@ -28,6 +28,9 @@
 
   <camelContext id="myCamel" xmlns="http://camel.apache.org/schema/spring">
 
+    <!-- property placeholder file -->
+    <propertyPlaceholder id="properties" location="rest.properties"/>
+
     <!-- configure rest to use the camel-servlet component, and use json binding mode -->
     <!-- and tell to output json in pretty print mode -->
     <!-- setup context path and port number that Apache Tomcat will deploy this application with,
@@ -96,9 +99,10 @@
 
       <get uri="/ping">
         <description>A ping service</description>
+        <param name="name" type="query" description="You can provide a name" dataType="string" defaultValue="{{defaultName}}"/>
         <route>
           <transform>
-            <constant>pong</constant>
+            <simple>pong ${header.name}</simple>
           </transform>
         </route>
       </get>

http://git-wip-us.apache.org/repos/asf/camel/blob/507916f5/examples/camel-example-swagger-xml/src/main/resources/rest.properties
----------------------------------------------------------------------
diff --git a/examples/camel-example-swagger-xml/src/main/resources/rest.properties b/examples/camel-example-swagger-xml/src/main/resources/rest.properties
new file mode 100644
index 0000000..43052e1
--- /dev/null
+++ b/examples/camel-example-swagger-xml/src/main/resources/rest.properties
@@ -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.
+## ---------------------------------------------------------------------------
+defaultName=Camel
\ No newline at end of file