You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2020/09/22 07:12:49 UTC
[camel-k-runtime] 01/03: yaml dsl: document how to create beans
using YAML #487
This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git
commit 0f96858c5de8e3b40a96c69682a8b08ce69b84d7
Author: Luca Burgazzoli <lb...@gmail.com>
AuthorDate: Tue Sep 22 08:28:18 2020 +0200
yaml dsl: document how to create beans using YAML #487
---
docs/modules/languages/pages/yaml.adoc | 47 +++++++++++++++++++++++++++++++++-
1 file changed, 46 insertions(+), 1 deletion(-)
diff --git a/docs/modules/languages/pages/yaml.adoc b/docs/modules/languages/pages/yaml.adoc
index 2a8f786..c94e563 100644
--- a/docs/modules/languages/pages/yaml.adoc
+++ b/docs/modules/languages/pages/yaml.adoc
@@ -7,7 +7,7 @@ The YAML DSL is current in preview support level.
== Defining a route
-A route is a sequence of elements, or `steps`, defined as follows:
+A route is collection of elements defined as follows:
[source,yaml]
----
@@ -112,6 +112,51 @@ set-body:
In case you want to use the data-format's default settings, you need to place an empty block as data format parameters, like `json: {}`
====
+== Defining beans
+
+In addition to the general support for creating beans provided by https://camel.apache.org/components/latest/others/main.html#_specifying_custom_beans[Camel Main], the YAML DSL provide a convenient syntax to define and configure them:
+
+[source,yaml]
+----
+- beans:
+ - name: beanFromMap # <1>
+ type: com.acme.MyBean # <2>
+ properties: # <3>
+ foo: bar
+----
+<1> the name of the bean which will be used to bound the instance to the Camel Registry
+<2> the full qualified class name of the bean
+<3> the properties of the bean to be set
+
+The properties of the bean can be defined using either a map or properties style as shown in the example below:
+
+[source,yaml]
+----
+- beans:
+ # map style
+ - name: beanFromMap
+ type: com.acme.MyBean
+ properties:
+ field1: 'f1'
+ field2: 'f2'
+ nested:
+ field1: 'nf1'
+ field2: 'nf2'
+ # properties style
+ - name: beanFromProps
+ type: com.acme.MyBean
+ properties:
+ field1: 'f1_p'
+ field2: 'f2_p'
+ nested.field1: 'nf1_p'
+ nested.field2: 'nf2_p'
+----
+
+[NOTE]
+====
+The `beans` elements can only be used as root element
+====
+
== Extending the DSL
The DSL is designed to be easily extended, so you can provide your own step handler which is discovered at runtime using Camel's factory finder.