This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push: new 21fb273 CAMEL-15389: camel-main - Add docs about camel.beans 21fb273 is described below commit 21fb273e19fd16eade988c07586ded28ef0a6c71 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Tue Aug 11 10:39:53 2020 +0200 CAMEL-15389: camel-main - Add docs about camel.beans --- core/camel-main/src/main/docs/main.adoc | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/core/camel-main/src/main/docs/main.adoc b/core/camel-main/src/main/docs/main.adoc index 57d18e4..ca16c36 100644 --- a/core/camel-main/src/main/docs/main.adoc +++ b/core/camel-main/src/main/docs/main.adoc @@ -278,6 +278,54 @@ Then we can create a bean instance with name `foo` and provide parameters to the camel.beans.foo = #class:com.foo.MyBean("Hello World", true, 123) ---- +=== Optional parameters on beans + +If a parameter on a bean is not mandatory then the parameter can be marked as optional using `?` syntax, as shown: + +[source,properties] +---- +camel.beans.foo = #class:com.foo.MyBean("Hello World", true, 123) +camel.beans.foo.?company = Acme +---- + +Then the company parameter is only set if `MyBean` has this option (silent ignore if no option present). +Otherwise if a parameter is set and the bean does not have such a parameter, then an exception is thrown by Camel. + +=== Nested parameters on beans + +You can configure nested parameters separating them via `.` (dot). + +For example given this `Country` class: + +[source,java] +---- +public class Country { + private String iso; + private String name; + + public void setIso(String iso) { + this.iso = iso; + } + + public void setName(String name) { + this.name = name; + } +} +---- + +Which is an option on the `MyBean` class. +Then we can then configure its iso and name parameter as shown below: + +[source,properties] +---- +camel.beans.foo = #class:com.foo.MyBean("Hello World", true, 123) +camel.beans.foo.country.iso = USA +camel.beans.foo.country.name = United States of America +---- + +Camel will automatic create an instance of `Country` if `MyBean` has a getter/setter for this option, and that the `Country` bean +has a default no-arg constructor. + === Configuring singleton beans by their type In the example above the SQL component was configured with the name of the `DataSource`. There can be situations where you know there is only