CAMEL-14297: add example for RouteBuilderConfigurer in lamvda style.
diff --git a/examples/camel-example-main-lambda/pom.xml b/examples/camel-example-main-lambda/pom.xml
new file mode 100644
index 0000000..55fe167
--- /dev/null
+++ b/examples/camel-example-main-lambda/pom.xml
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel.example</groupId>
+ <artifactId>examples</artifactId>
+ <version>3.5.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-example-main-lambda</artifactId>
+ <packaging>jar</packaging>
+ <name>Camel :: Example :: Main :: Lambda</name>
+ <description>Camel routes lambda style</description>
+
+ <properties>
+ <category>Beginner</category>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <!-- Add Camel BOM -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-bom</artifactId>
+ <version>${camel.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-main</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-quartz</artifactId>
+ </dependency>
+
+ <!-- logging -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <version>${log4j2-version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ <version>${logback-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>${logback-version}</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-maven-plugin</artifactId>
+ <version>${camel.version}</version>
+ <configuration>
+ <logClasspath>false</logClasspath>
+ <mainClass>org.apache.camel.example.MyApplication</mainClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/examples/camel-example-main-lambda/readme.adoc b/examples/camel-example-main-lambda/readme.adoc
new file mode 100644
index 0000000..e55faea
--- /dev/null
+++ b/examples/camel-example-main-lambda/readme.adoc
@@ -0,0 +1,31 @@
+== Camel Example Main Lambda
+
+This example demonstrates how to use `RouteBuilderConfigurer` as a way of defining Camel routes
+using lambda style.
+
+ rb -> rb.from("timer:foo").log("Hello Lambda");
+
+The `RouteBuilderConfigurer` is a functional interface that makes defining routes with lambda style
+easy. All you need to do is to create a method that returns `RouteBuilderConfigurer` and mark
+the method with `@BindToRegistry` or if using Spring Boot `@Bean` or `@Produce` for CDI/Quarkus.
+
+See the `MyConfiguration.java` in this example how this class is the configuration class and where
+routes are defined.
+
+Multiple routes can be defined by having multiple methods.
+
+=== How to run
+
+You can run this example using
+
+ mvn camel:run
+
+=== Help and contributions
+
+If you hit any problem using Camel or have some feedback, then please
+https://camel.apache.org/support.html[let us know].
+
+We also love contributors, so
+https://camel.apache.org/contributing.html[get involved] :-)
+
+The Camel riders!
diff --git a/examples/camel-example-main-lambda/src/main/java/org/apache/camel/example/MyApplication.java b/examples/camel-example-main-lambda/src/main/java/org/apache/camel/example/MyApplication.java
new file mode 100644
index 0000000..1013f33
--- /dev/null
+++ b/examples/camel-example-main-lambda/src/main/java/org/apache/camel/example/MyApplication.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.example;
+
+import org.apache.camel.main.Main;
+
+/**
+ * Main class that boot the Camel application
+ */
+public final class MyApplication {
+
+ private MyApplication() {
+ }
+
+ public static void main(String[] args) throws Exception {
+ // use Camels Main class
+ Main main = new Main();
+ // lets use a configuration class (you can specify multiple classes)
+ // (properties are automatic loaded from application.properties)
+ // the configuration class has the configuration and also the routes to be used
+ main.configure().addConfigurationClass(MyConfiguration.class);
+ // now keep the application running until the JVM is terminated (ctrl + c or sigterm)
+ main.run(args);
+ }
+
+}
diff --git a/examples/camel-example-main-lambda/src/main/java/org/apache/camel/example/MyBean.java b/examples/camel-example-main-lambda/src/main/java/org/apache/camel/example/MyBean.java
new file mode 100644
index 0000000..1e1bdb8
--- /dev/null
+++ b/examples/camel-example-main-lambda/src/main/java/org/apache/camel/example/MyBean.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.example;
+
+public class MyBean {
+
+ private String hi;
+ private String bye;
+
+ public MyBean(String hi, String bye) {
+ this.hi = hi;
+ this.bye = bye;
+ }
+
+ public String hello() {
+ return hi + " how are you?";
+ }
+
+ public String bye() {
+ return bye + " World";
+ }
+}
diff --git a/examples/camel-example-main-lambda/src/main/java/org/apache/camel/example/MyConfiguration.java b/examples/camel-example-main-lambda/src/main/java/org/apache/camel/example/MyConfiguration.java
new file mode 100644
index 0000000..32a8b14
--- /dev/null
+++ b/examples/camel-example-main-lambda/src/main/java/org/apache/camel/example/MyConfiguration.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.example;
+
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.PropertyInject;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.builder.RouteBuilderConfigurer;
+
+/**
+ * Class to configure the Camel application.
+ */
+public class MyConfiguration {
+
+ @BindToRegistry
+ public MyBean myBean(@PropertyInject("hi") String hi, @PropertyInject("bye") String bye) {
+ // this will create an instance of this bean with the name of the method (eg myBean)
+ return new MyBean(hi, bye);
+ }
+
+ /**
+ * Here we define a route as a method that returns a RouteBuilderConfigurer instance.
+ * This allows us to use lambda style.
+ */
+ @BindToRegistry
+ public RouteBuilderConfigurer myRoute() {
+ return rb -> rb.from("quartz:foo?cron={{myCron}}")
+ .bean("myBean", "hello")
+ .log("${body}")
+ .bean("myBean", "bye")
+ .log("${body}");
+ }
+
+}
diff --git a/examples/camel-example-main-lambda/src/main/resources/application.properties b/examples/camel-example-main-lambda/src/main/resources/application.properties
new file mode 100644
index 0000000..4da5cc9
--- /dev/null
+++ b/examples/camel-example-main-lambda/src/main/resources/application.properties
@@ -0,0 +1,35 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+# to configure camel main
+# here you can configure options on camel main (see MainConfigurationProperties class)
+camel.main.name = MyCoolCamel
+
+# extended runtime statistics about bean introspection usage (java reflection)
+camel.main.bean-introspection-extended-statistics=true
+camel.main.bean-introspection-logging-level=INFO
+
+# to configure the camel quartz component
+# here we can configure the options on the component level (and we can use dash-naming-style)
+camel.component.quartz.start-delayed-seconds = 3
+
+# properties used in the route
+myCron = 0/2 * * * * ?
+
+# application properties
+hi = Hello
+bye = Bye
diff --git a/examples/camel-example-main-lambda/src/main/resources/logback.xml b/examples/camel-example-main-lambda/src/main/resources/logback.xml
new file mode 100644
index 0000000..a798d0b
--- /dev/null
+++ b/examples/camel-example-main-lambda/src/main/resources/logback.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="INFO">
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration>
diff --git a/examples/pom.xml b/examples/pom.xml
index caab63b..2798530 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -125,6 +125,7 @@
<module>camel-example-main-artemis</module>
<module>camel-example-main-endpointdsl</module>
<module>camel-example-main-health</module>
+ <module>camel-example-main-lambda</module>
<module>camel-example-main-tiny</module>
<module>camel-example-main-xml</module>
<module>camel-example-management</module>