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 2023/08/29 19:11:56 UTC
[camel-kamelets-examples] branch main updated: Update example to use classic Spring XML XML file
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-kamelets-examples.git
The following commit(s) were added to refs/heads/main by this push:
new 8a65c3f Update example to use classic Spring XML <beans> XML file
8a65c3f is described below
commit 8a65c3f485f752b77587a7cc0fda075a64f93e42
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Aug 29 20:41:24 2023 +0200
Update example to use classic Spring XML <beans> XML file
---
jbang/xml-to-yaml/OrderService.java | 7 ++++++-
jbang/xml-to-yaml/README.adoc | 4 ++--
jbang/xml-to-yaml/application.properties | 2 ++
jbang/xml-to-yaml/order-spring.xml | 35 ++++++++++++++++++++------------
4 files changed, 32 insertions(+), 16 deletions(-)
diff --git a/jbang/xml-to-yaml/OrderService.java b/jbang/xml-to-yaml/OrderService.java
index 36495bf..3f2e86c 100644
--- a/jbang/xml-to-yaml/OrderService.java
+++ b/jbang/xml-to-yaml/OrderService.java
@@ -7,6 +7,11 @@ public class OrderService {
private String customer;
private Address address;
+ public OrderService(boolean customer, Address address) {
+ this.customer = customer ? "Acme" : "None";
+ this.address = address;
+ }
+
public void setCustomer(String customer) {
this.customer = customer;
}
@@ -24,7 +29,7 @@ public class OrderService {
}
public String processorOrder(String id) {
- return "Order " + id + " ordered by " + customer + " to " + address.getStreet();
+ return "Order2 " + id + " ordered by " + customer + " to " + address.getStreet();
}
}
\ No newline at end of file
diff --git a/jbang/xml-to-yaml/README.adoc b/jbang/xml-to-yaml/README.adoc
index d001d5a..dfb32c4 100644
--- a/jbang/xml-to-yaml/README.adoc
+++ b/jbang/xml-to-yaml/README.adoc
@@ -1,6 +1,6 @@
== XML to YAML
-This example shows XML DSL with both bean and routes using the new <camel> root tag.
+This example shows classic Spring XML file with <bean> and <camelContext> with embedded <route>.
The XML can be migrated to YAML DSL using Camel JBang.
@@ -47,7 +47,7 @@ This can also be done explicit from CLI, by executing:
$ camel transform * --format=yaml --output=my-dump
----
-This will transform the Camel XML DSL into YAML and store the output in the my-dump directory.
+This will transform the XML DSL into YAML DSL and store the output in the my-dump directory.
=== Help and contributions
diff --git a/jbang/xml-to-yaml/application.properties b/jbang/xml-to-yaml/application.properties
new file mode 100644
index 0000000..ef1be51
--- /dev/null
+++ b/jbang/xml-to-yaml/application.properties
@@ -0,0 +1,2 @@
+zipCode = 90210
+streetName = Gardenstreet 444
diff --git a/jbang/xml-to-yaml/order-spring.xml b/jbang/xml-to-yaml/order-spring.xml
index 29e0f81..e13393e 100644
--- a/jbang/xml-to-yaml/order-spring.xml
+++ b/jbang/xml-to-yaml/order-spring.xml
@@ -1,16 +1,23 @@
-<camel>
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
- <!-- embedded spring-xml beans -->
- <beans xmlns="http://www.springframework.org/schema/beans">
- <bean id="orderService" class="com.foo.OrderService">
- <property name="customer" value="Acme"/>
- <property name="address" ref="office"/>
- </bean>
- <bean id="office" class="com.foo.Address">
- <property name="zip" value="1234"/>
- <property name="street" value="Gardenstreet 444"/>
- </bean>
- </beans>
+ <!-- spring beans -->
+ <bean id="orderService" class="com.foo.OrderService">
+ <constructor-arg index="0" value="true"/>
+ <constructor-arg index="1" ref="office"/>
+ </bean>
+ <!-- uses spring property placeholder ${xxx} syntax -->
+ <bean id="office" class="com.foo.Address">
+ <property name="zip" value="${zipCode}"/>
+ <property name="street" value="${streetName}"/>
+ </bean>
+
+ <!-- embed Camel with routes -->
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="timer:xml?period={{time:1000}}"/>
@@ -21,4 +28,6 @@
<log message="${body}"/>
</route>
-</camel>
+ </camelContext>
+
+</beans>