You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pp...@apache.org on 2020/09/28 15:39:34 UTC
[camel-quarkus] 03/03: Document camel main xml configuration
properties
This is an automated email from the ASF dual-hosted git repository.
ppalaga pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 4be271fd1d83cbda9d8480b5e7f98abf0c9fc7f1
Author: James Netherton <ja...@gmail.com>
AuthorDate: Mon Sep 28 10:33:00 2020 +0100
Document camel main xml configuration properties
Fixes #1823
---
docs/modules/ROOT/pages/user-guide/bootstrap.adoc | 88 +++++++++++++++++++++++
integration-tests/main-xml-io/pom.xml | 2 +-
integration-tests/main-xml-jaxb/pom.xml | 13 ++++
3 files changed, 102 insertions(+), 1 deletion(-)
diff --git a/docs/modules/ROOT/pages/user-guide/bootstrap.adoc b/docs/modules/ROOT/pages/user-guide/bootstrap.adoc
index 5eefc32..b61d35b 100644
--- a/docs/modules/ROOT/pages/user-guide/bootstrap.adoc
+++ b/docs/modules/ROOT/pages/user-guide/bootstrap.adoc
@@ -102,3 +102,91 @@ public class Main {
====
It is recommended to perform very little logic in the Java Main.
====
+
+=== XML Configuration
+
+In order to configure Camel routes, rests or templates in XML, you must add a Camel XML parser dependency to the classpath. E.g either `camel-quarkus-xml-io` or
+`camel-quarkus-xml-jaxb`. `camel-quarkus-xml-io` is preferred due to its lightweight implementation.
+
+==== Routes
+
+With Camel Main, you can set a property that points to the location of route XML files:
+
+[source,properties]
+----
+camel.main.xml-routes = routes/routes.xml, file:src/main/routes/other-routes.xml
+----
+
+[NOTE]
+====
+Path globbing like `camel.main.xml-routes = *./routes.xml` currently does not work in native mode.
+====
+
+Spring XML with `<beans>` or Blueprint XML with `<blueprint>` elements are not supported. The route XML should be in the simplified version like:
+
+[source,xml]
+----
+<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://camel.apache.org/schema/spring"
+ xsi:schemaLocation="
+ http://camel.apache.org/schema/spring
+ http://camel.apache.org/schema/spring/camel-spring.xsd">
+
+ <route id="xml-route">
+ <from uri="timer:from-xml?period=1000"/>
+ <log message="Hello XML!"/>
+ </route>
+
+</routes>
+----
+
+==== REST DSL
+
+The Camel https://camel.apache.org/manual/latest/rest-dsl.html[REST DSL] can be defined in XML and configured with Camel Main via a property:
+
+[source,properties]
+----
+camel.main.xml-rests = rests/rests.xml, file:src/main/rests/other-rests.xml
+----
+
+The XML for the REST configuration looks like:
+
+[source,xml]
+----
+<rests xmlns="http://camel.apache.org/schema/spring">
+ <rest id="greeting" path="/greeting">
+ <get uri="/hello">
+ <setBody>
+ <constant>Hello World!</constant>
+ </setBody>
+ </get>
+ </rest>
+</rests>
+----
+
+==== Route Templates
+
+https://camel.apache.org/manual/latest/route-template.html[Route templates] can be defined in XML and configured with Camel Main via a property:
+
+[source,properties]
+----
+camel.main.xml-route-templates = templates/route-template.xml, file:src/main/rests/other-route-template.xml
+----
+
+The XML for the route template configuration looks like:
+
+[source,xml]
+----
+<routeTemplates xmlns="http://camel.apache.org/schema/spring">
+ <routeTemplate id="myTemplate">
+ <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="${body}"/>
+ </route>
+ </routeTemplate>
+</routeTemplates>
+----
diff --git a/integration-tests/main-xml-io/pom.xml b/integration-tests/main-xml-io/pom.xml
index 38b6274..3e5b89a 100644
--- a/integration-tests/main-xml-io/pom.xml
+++ b/integration-tests/main-xml-io/pom.xml
@@ -127,7 +127,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-platform-http-deployment</artifactId>
+ <artifactId>camel-quarkus-rest-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
diff --git a/integration-tests/main-xml-jaxb/pom.xml b/integration-tests/main-xml-jaxb/pom.xml
index 344ed86..5c954d2 100644
--- a/integration-tests/main-xml-jaxb/pom.xml
+++ b/integration-tests/main-xml-jaxb/pom.xml
@@ -127,6 +127,19 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-rest-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-timer-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>