This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot-examples.git


The following commit(s) were added to refs/heads/main by this push:
     new 8d59dfd  Updated example with xml template
8d59dfd is described below

commit 8d59dfd6ea0af2f2b8f0fd56962f30261641c48a
Author: Claus Ibsen <[email protected]>
AuthorDate: Tue Oct 26 15:47:50 2021 +0200

    Updated example with xml template
---
 routetemplate/readme.adoc                          |  5 +++-
 .../main/java/sample/camel/MyRouteTemplates.java   |  5 +++-
 routetemplate/src/main/resources/application.yaml  |  5 ++--
 .../src/main/resources/mycamel/my-template.xml     | 35 ++++++++++++++++++++++
 4 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/routetemplate/readme.adoc b/routetemplate/readme.adoc
index 2a04c34..7a85373 100644
--- a/routetemplate/readme.adoc
+++ b/routetemplate/readme.adoc
@@ -3,7 +3,10 @@
 This examples shows how to use Route Templates (parameterized routes) to 
specify a skeleton route
 which can be used for creating and adding new routes via parameters.
 
-The route template is defined via Java or XML DSL (RouteBuilder) in the 
`MyRouteTemplates.java` source file.
+We have prepared the example with the route template in both XML and Java DSL
+
+The XML (default in use) is located in `src/main/resources/mycamel` folder.
+The Java is in the `MyRouteTemplates.java` source file.
 
 The `application.properties` is used to create two routes from the template 
using different set of parameters.
 
diff --git a/routetemplate/src/main/java/sample/camel/MyRouteTemplates.java 
b/routetemplate/src/main/java/sample/camel/MyRouteTemplates.java
index b655e07..931b399 100644
--- a/routetemplate/src/main/java/sample/camel/MyRouteTemplates.java
+++ b/routetemplate/src/main/java/sample/camel/MyRouteTemplates.java
@@ -29,6 +29,8 @@ public class MyRouteTemplates extends RouteBuilder {
 
     @Override
     public void configure() throws Exception {
+        // in this example we have created the template in XML and this is 
disabled
+        /*
         // create a route template with the given name
         routeTemplate("myTemplate")
             // here we define the required input parameters (can have default 
values)
@@ -40,6 +42,7 @@ public class MyRouteTemplates extends RouteBuilder {
             // we can also use {{propertyName}} to refer to property 
placeholders
             .from("timer:{{name}}?period={{myPeriod}}")
                 .setBody(simple("{{greeting}} ${body}"))
-                .log("${body}");
+                .log("Java says ${body}");
+         */
     }
 }
diff --git a/routetemplate/src/main/resources/application.yaml 
b/routetemplate/src/main/resources/application.yaml
index 2d44f44..cd1b49c 100644
--- a/routetemplate/src/main/resources/application.yaml
+++ b/routetemplate/src/main/resources/application.yaml
@@ -18,14 +18,15 @@
 camel:
   springboot:
     name: MyCamel
+    routes-include-pattern: classpath:mycamel/*.xml
 
   route-template:
     config:
-      -0.template-id: myTemplate
+      -0.template-id: myXmlTemplate
       -0.route-id: first
       -0.name: one
       -0.greeting: Hello
-      -1.template-id: myTemplate
+      -1.template-id: myXmlTemplate
       -1.route-id: second
       -1.name: two
       -1.greeting: Bonjour
diff --git a/routetemplate/src/main/resources/mycamel/my-template.xml 
b/routetemplate/src/main/resources/mycamel/my-template.xml
new file mode 100644
index 0000000..0ab44ac
--- /dev/null
+++ b/routetemplate/src/main/resources/mycamel/my-template.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<routeTemplates xmlns="http://camel.apache.org/schema/spring";>
+
+    <routeTemplate id="myXmlTemplate">
+        <templateParameter name="name"/>
+        <templateParameter name="greeting"/>
+        <templateParameter name="myPeriod" defaultValue="3s"/>
+        <route>
+            <from uri="timer:{{name}}?period={{myPeriod}}"/>
+            <setBody>
+                <simple>{{greeting}} ${body}</simple>
+            </setBody>
+            <log message="XML says ${body}"/>
+        </route>
+    </routeTemplate>
+
+</routeTemplates>

Reply via email to