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.git
commit 559029433517e076bb4e0a2ff2583154328459a2 Author: Claus Ibsen <[email protected]> AuthorDate: Mon Jun 15 13:16:07 2026 +0200 chore: add YAML DSL examples to existing tabs blocks in component docs Co-Authored-By: Claude <[email protected]> Signed-off-by: Claus Ibsen <[email protected]> --- .../camel-bean/src/main/docs/bean-component.adoc | 16 +++++- .../camel-bean/src/main/docs/bean-language.adoc | 18 ++++++ .../src/main/docs/beanio-dataformat.adoc | 33 ++++++++++- .../camel-cron/src/main/docs/cron-component.adoc | 21 ++++++- .../src/main/docs/pgp-dataformat.adoc | 21 ++++++- .../camel-csv/src/main/docs/csv-dataformat.adoc | 67 +++++++++++++++++++++- .../src/main/docs/cxf-component.adoc | 16 ++++++ .../src/main/docs/dataformat-component.adoc | 28 ++++++--- .../src/main/docs/datasonnet-language.adoc | 53 +++++++++++++++++ .../src/main/docs/direct-component.adoc | 28 ++++++++- .../src/main/docs/dynamic-router-component.adoc | 16 +++++- .../camel-joor/src/main/docs/joor-language.adoc | 35 ++++++++++- .../camel-netty/src/main/docs/netty-component.adoc | 42 ++++++++++---- .../src/main/docs/undertow-component.adoc | 12 ++++ 14 files changed, 376 insertions(+), 30 deletions(-) diff --git a/components/camel-bean/src/main/docs/bean-component.adoc b/components/camel-bean/src/main/docs/bean-component.adoc index bf82aa613b64..a2ff792b0be6 100644 --- a/components/camel-bean/src/main/docs/bean-component.adoc +++ b/components/camel-bean/src/main/docs/bean-component.adoc @@ -66,12 +66,24 @@ from("direct:hello") XML:: + [source,xml] ----------------------------- +---- <route> <from uri="direct:hello"/> <to uri="bean:com.foo.MyBean"/> </route> ----------------------------- +---- + +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: direct:hello + steps: + - to: + uri: bean:com.foo.MyBean +---- ==== What happens is that when the exchange is routed to the MyBean, then Camel diff --git a/components/camel-bean/src/main/docs/bean-language.adoc b/components/camel-bean/src/main/docs/bean-language.adoc index 026d9b1fe69d..093e200f0ae8 100644 --- a/components/camel-bean/src/main/docs/bean-language.adoc +++ b/components/camel-bean/src/main/docs/bean-language.adoc @@ -59,6 +59,24 @@ XML:: </filter> </route> ---- + +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: activemq:topic:OrdersTopic + steps: + - filter: + expression: + method: + ref: myBean + method: isGoldCustomer + steps: + - to: + uri: activemq:BigSpendersQueue +---- ==== The bean could be implemented as follows: diff --git a/components/camel-beanio/src/main/docs/beanio-dataformat.adoc b/components/camel-beanio/src/main/docs/beanio-dataformat.adoc index ec480b43169a..79955d882f9e 100644 --- a/components/camel-beanio/src/main/docs/beanio-dataformat.adoc +++ b/components/camel-beanio/src/main/docs/beanio-dataformat.adoc @@ -81,8 +81,37 @@ XML:: <to uri="mock:beanio-marshal"/> </route> ---- -To use the BeanIO data format in XML, you need to configure it using the -`<beanio>` XML tag as shown below. The routes are similar to the example above. + +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: direct:unmarshal + steps: + - unmarshal: + beanio: + mapping: org/apache/camel/dataformat/beanio/mappings.xml + streamName: employeeFile + - split: + expression: + simple: + expression: "${body}" + steps: + - to: + uri: mock:beanio-unmarshal +- route: + from: + uri: direct:marshal + steps: + - marshal: + beanio: + mapping: org/apache/camel/dataformat/beanio/mappings.xml + streamName: employeeFile + - to: + uri: mock:beanio-marshal +---- ==== The first route is for transforming CSV data into a `List<Employee>` Java objects. diff --git a/components/camel-cron/src/main/docs/cron-component.adoc b/components/camel-cron/src/main/docs/cron-component.adoc index ea2cb4fd4f0e..e5873e89ae94 100644 --- a/components/camel-cron/src/main/docs/cron-component.adoc +++ b/components/camel-cron/src/main/docs/cron-component.adoc @@ -69,7 +69,7 @@ from("cron:tab?schedule=0/1+*+*+*+*+?") XML:: + [source,xml] -------------- +---- <route> <from uri="cron:tab?schedule=0/1+*+*+*+*+?"/> <setBody> @@ -77,7 +77,24 @@ XML:: </setBody> <to uri="log:info"/> </route> -------------- +---- + +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: cron:tab + parameters: + schedule: "0/1+*+*+*+*+?" + steps: + - setBody: + constant: + expression: event + - to: + uri: log:info +---- ==== diff --git a/components/camel-crypto-pgp/src/main/docs/pgp-dataformat.adoc b/components/camel-crypto-pgp/src/main/docs/pgp-dataformat.adoc index 65d8a16ce597..d090e9b8fd56 100644 --- a/components/camel-crypto-pgp/src/main/docs/pgp-dataformat.adoc +++ b/components/camel-crypto-pgp/src/main/docs/pgp-dataformat.adoc @@ -101,7 +101,7 @@ from("direct:pgp-encrypt") .unmarshal().pgp("file:secring.gpg", "[email protected]", "letmein"); ---- -Spring XML:: +XML:: + [source,xml] ---- @@ -112,6 +112,25 @@ Spring XML:: </route> ---- +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: direct:pgp-encrypt + steps: + - marshal: + pgp: + keyFileName: "file:pubring.gpg" + keyUserid: "[email protected]" + - unmarshal: + pgp: + keyFileName: "file:secring.gpg" + keyUserid: "[email protected]" + password: letmein +---- + ==== === Working with the previous example diff --git a/components/camel-csv/src/main/docs/csv-dataformat.adoc b/components/camel-csv/src/main/docs/csv-dataformat.adoc index 78964040f815..68d6b99c5f63 100644 --- a/components/camel-csv/src/main/docs/csv-dataformat.adoc +++ b/components/camel-csv/src/main/docs/csv-dataformat.adoc @@ -80,6 +80,20 @@ XML:: </route> ------------------------------------------------------- +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: direct:start + steps: + - marshal: + csv: {} + - to: + uri: mock:result +---- + ==== then it will produce @@ -195,7 +209,22 @@ XML:: </marshal> <to uri="mock:result" /> </route> -------------------------------------------------------- +------------------------------------------------------- + +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: direct:start + steps: + - marshal: + csv: + delimiter: "|" + - to: + uri: mock:result +---- ==== @@ -311,6 +340,23 @@ XML:: </route> --------------------------------------------------- +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: direct:start + steps: + - unmarshal: + csv: + skipFirstLine: true + - to: + uri: bean:myCsvHandler + parameters: + method: doHandleCsv +---- + ==== @@ -346,7 +392,7 @@ from("direct:start") .to("bean:myCsvHandler?method=doHandleCsv"); ---------------------------------------------- -Spring XML:: +XML:: + [source,xml] --------------------------------------------------- @@ -359,6 +405,23 @@ Spring XML:: </route> --------------------------------------------------- +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: direct:start + steps: + - unmarshal: + csv: + delimiter: "|" + - to: + uri: bean:myCsvHandler + parameters: + method: doHandleCsv +---- + ==== diff --git a/components/camel-cxf/camel-cxf-soap/src/main/docs/cxf-component.adoc b/components/camel-cxf/camel-cxf-soap/src/main/docs/cxf-component.adoc index 6b1823afae1d..3bf710113b78 100644 --- a/components/camel-cxf/camel-cxf-soap/src/main/docs/cxf-component.adoc +++ b/components/camel-cxf/camel-cxf-soap/src/main/docs/cxf-component.adoc @@ -747,6 +747,22 @@ XML:: <process ref="InsertResponseOutHeaderProcessor" /> </route> ---- + +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: cxf:bean:routerRelayEndpointWithInsertion + steps: + - process: + ref: InsertRequestOutHeaderProcessor + - to: + uri: cxf:bean:serviceRelayEndpointWithInsertion + - process: + ref: InsertResponseOutHeaderProcessor +---- ==== SOAP headers are propagated to and from Camel Message headers. The Camel diff --git a/components/camel-dataformat/src/main/docs/dataformat-component.adoc b/components/camel-dataformat/src/main/docs/dataformat-component.adoc index f1e897bc0f67..77c8134486fb 100644 --- a/components/camel-dataformat/src/main/docs/dataformat-component.adoc +++ b/components/camel-dataformat/src/main/docs/dataformat-component.adoc @@ -60,13 +60,27 @@ XML:: + [source,xml] ---- -<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> - <route> - <from uri="activemq:My.Queue"/> - <to uri="dataformat:jaxb:unmarshal?contextPath=com.acme.model"/> - <to uri="mqseries:Another.Queue"/> - </route> -</camelContext> +<route> + <from uri="activemq:My.Queue"/> + <to uri="dataformat:jaxb:unmarshal?contextPath=com.acme.model"/> + <to uri="mqseries:Another.Queue"/> +</route> +---- + +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: activemq:My.Queue + steps: + - to: + uri: dataformat:jaxb:unmarshal + parameters: + contextPath: com.acme.model + - to: + uri: mqseries:Another.Queue ---- ==== diff --git a/components/camel-datasonnet/src/main/docs/datasonnet-language.adoc b/components/camel-datasonnet/src/main/docs/datasonnet-language.adoc index fe7e731227db..5911f22ecc6f 100644 --- a/components/camel-datasonnet/src/main/docs/datasonnet-language.adoc +++ b/components/camel-datasonnet/src/main/docs/datasonnet-language.adoc @@ -275,6 +275,23 @@ XML:: <to uri="mock:camel"/> </route> ----------------------------------------------------------------------------- + +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: direct:in + steps: + - setBody: + expression: + datasonnet: + expression: "'hello, ' + cml.properties('toGreet')" + resultType: java.lang.String + - to: + uri: mock:camel +---- ==== === Loading script from external resource @@ -317,6 +334,23 @@ XML:: </filter> </route> ----------------------------------------------------------------------------- + +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: queue:foo + steps: + - filter: + expression: + datasonnet: + expression: "ds.arrays.firstWith(body.lineItems, function(item) item > 100) != null" + steps: + - to: + uri: queue:bar +---- ==== @@ -348,6 +382,25 @@ XML:: </filter> </route> ----------------------------------------------------------------------------- + +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: queue:foo + steps: + - transform: + expression: + datasonnet: + expression: "ds.filter(body.lineItems, function(item) item > 100)" + resultType: java.lang.String + bodyMediaType: application/xml + outputMediaType: application/json + - to: + uri: queue:bar +---- ==== diff --git a/components/camel-direct/src/main/docs/direct-component.adoc b/components/camel-direct/src/main/docs/direct-component.adoc index 05f04bb00c94..73b8fcd53e24 100644 --- a/components/camel-direct/src/main/docs/direct-component.adoc +++ b/components/camel-direct/src/main/docs/direct-component.adoc @@ -63,7 +63,7 @@ from("direct:processOrder") .to("activemq:queue:order.out"); ---- -Spring XML:: +XML:: + [source,xml] ---- @@ -80,6 +80,32 @@ Spring XML:: </route> ---- +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: activemq:queue:order.in + steps: + - to: + uri: bean:orderService + parameters: + method: validate + - to: + uri: direct:processOrder +- route: + from: + uri: direct:processOrder + steps: + - to: + uri: bean:orderService + parameters: + method: process + - to: + uri: activemq:queue:order.out +---- + ==== See also samples from the xref:seda-component.adoc[SEDA] component, how they can be used together. diff --git a/components/camel-dynamic-router/src/main/docs/dynamic-router-component.adoc b/components/camel-dynamic-router/src/main/docs/dynamic-router-component.adoc index 32935b5b00b8..e14d7c409515 100644 --- a/components/camel-dynamic-router/src/main/docs/dynamic-router-component.adoc +++ b/components/camel-dynamic-router/src/main/docs/dynamic-router-component.adoc @@ -102,16 +102,28 @@ Java:: from("direct:start").to("dynamic-router:orders"); ---- -Spring XML:: +XML:: + .Example XML Route Definition [source,xml] ---- <route> <from uri="direct:start"/> - <to uri="dynamic-router:nameOfYourChannel"/> + <to uri="dynamic-router:orders"/> </route> ---- + +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: direct:start + steps: + - to: + uri: dynamic-router:orders +---- ==== == Examples diff --git a/components/camel-joor/src/main/docs/joor-language.adoc b/components/camel-joor/src/main/docs/joor-language.adoc index 0787531fad3d..1c50675fac33 100644 --- a/components/camel-joor/src/main/docs/joor-language.adoc +++ b/components/camel-joor/src/main/docs/joor-language.adoc @@ -242,7 +242,7 @@ from("seda:orders") .to("seda:upper"); ---- -XML DSL:: +XML:: + [source,xml] ---- @@ -255,6 +255,22 @@ XML DSL:: </route> ---- +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: seda:orders + steps: + - transform: + expression: + joor: + expression: "message.getBody(String.class).toUpperCase()" + - to: + uri: seda:upper +---- + ==== === Multi statements @@ -316,6 +332,23 @@ In XML DSL it's easier because you can turn off pre-compilation in the `<joor>` </route> ---- +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: jms:incoming + steps: + - transform: + expression: + joor: + expression: "resource:file:src/main/resources/orders.joor" + preCompile: false + - to: + uri: jms:orders +---- + ==== === Lambda-based AggregationStrategy diff --git a/components/camel-netty/src/main/docs/netty-component.adoc b/components/camel-netty/src/main/docs/netty-component.adoc index 639fae28075a..dfba17778a66 100644 --- a/components/camel-netty/src/main/docs/netty-component.adoc +++ b/components/camel-netty/src/main/docs/netty-component.adoc @@ -260,16 +260,38 @@ XML:: + [source,xml] ---- -<camelContext id="multiple-netty-codecs-context" xmlns="http://camel.apache.org/schema/spring"> - <route> - <from uri="direct:multiple-codec"/> - <to uri="netty:tcp://0.0.0.0:5150?encoders=#encoders&sync=false"/> - </route> - <route> - <from uri="netty:tcp://0.0.0.0:5150?decoders=#length-decoder,#string-decoder&sync=false"/> - <to uri="mock:multiple-codec"/> - </route> -</camelContext> +<route> + <from uri="direct:multiple-codec"/> + <to uri="netty:tcp://0.0.0.0:5150?encoders=#encoders&sync=false"/> +</route> +<route> + <from uri="netty:tcp://0.0.0.0:5150?decoders=#length-decoder,#string-decoder&sync=false"/> + <to uri="mock:multiple-codec"/> +</route> +---- + +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: direct:multiple-codec + steps: + - to: + uri: "netty:tcp://0.0.0.0:5150" + parameters: + encoders: "#encoders" + sync: false +- route: + from: + uri: "netty:tcp://0.0.0.0:5150" + parameters: + decoders: "#length-decoder,#string-decoder" + sync: false + steps: + - to: + uri: mock:multiple-codec ---- ==== diff --git a/components/camel-undertow/src/main/docs/undertow-component.adoc b/components/camel-undertow/src/main/docs/undertow-component.adoc index c95b449e943e..6122ade38ba8 100644 --- a/components/camel-undertow/src/main/docs/undertow-component.adoc +++ b/components/camel-undertow/src/main/docs/undertow-component.adoc @@ -255,6 +255,18 @@ XML:: </route> ---- +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: direct:start + steps: + - to: + uri: undertow:http://www.google.com +---- + ==== === HTTP Consumer Example
