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 2022/04/12 11:14:43 UTC

[camel-spring-boot-examples] branch main updated: Make example old school with style beans

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-spring-boot-examples.git


The following commit(s) were added to refs/heads/main by this push:
     new 02c1935  Make example old school with <bean> style beans
02c1935 is described below

commit 02c19359a31f7153f558b7b69f6451a053ce2a42
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 12 13:14:34 2022 +0200

    Make example old school with <bean> style beans
---
 xml-import/src/main/java/sample/camel/SampleBean.java | 16 ++++++++--------
 xml-import/src/main/resources/application.properties  | 10 ----------
 xml-import/src/main/resources/my-camel.xml            | 11 ++++++++++-
 3 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/xml-import/src/main/java/sample/camel/SampleBean.java b/xml-import/src/main/java/sample/camel/SampleBean.java
index 21230eb..e62fe4a 100644
--- a/xml-import/src/main/java/sample/camel/SampleBean.java
+++ b/xml-import/src/main/java/sample/camel/SampleBean.java
@@ -16,21 +16,21 @@
  */
 package sample.camel;
 
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
 /**
  * A bean that returns a message when you call the {@link #saySomething()} method.
- * <p/>
- * Uses <tt>@Component("myBean")</tt> to register this bean with the name <tt>myBean</tt>
- * that we use in the Camel route to lookup this bean.
  */
-@Component("myBean")
 public class SampleBean {
 
-    @Value("${greeting}")
     private String say;
 
+    public String getSay() {
+        return say;
+    }
+
+    public void setSay(String say) {
+        this.say = say;
+    }
+
     public String saySomething() {
         return say;
     }
diff --git a/xml-import/src/main/resources/application.properties b/xml-import/src/main/resources/application.properties
index 67115c8..7ab7ca9 100644
--- a/xml-import/src/main/resources/application.properties
+++ b/xml-import/src/main/resources/application.properties
@@ -15,16 +15,6 @@
 ## limitations under the License.
 ## ---------------------------------------------------------------------------
 
-# the name of Camel
-camel.springboot.name = SampleCamel
-
-# to automatic shutdown the JVM after a period of time
-#camel.springboot.duration-max-seconds=60
-#camel.springboot.duration-max-messages=100
-
-# add for example: &repeatCount=5 to the timer endpoint to make Camel idle
-#camel.springboot.duration-max-idle-seconds=15
-
 # properties used in the Camel route and beans
 # --------------------------------------------
 
diff --git a/xml-import/src/main/resources/my-camel.xml b/xml-import/src/main/resources/my-camel.xml
index 3fc6e0f..db2f14d 100644
--- a/xml-import/src/main/resources/my-camel.xml
+++ b/xml-import/src/main/resources/my-camel.xml
@@ -23,10 +23,18 @@
          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">
 
+  <!-- define the say bean -->
+  <bean id="myBean" class="sample.camel.SampleBean">
+    <property name="say" value="${greeting}"/> <!-- use spring property ${ } placeholder syntax -->
+  </bean>
+
+  <!-- embed Camel with routes -->
   <camelContext id="SampleCamel" xmlns="http://camel.apache.org/schema/spring">
+
     <route id="hello">
-      <from uri="timer:hello?period={{timer.period}}"/>
+      <from uri="timer:hello?period={{timer.period}}"/> <!-- use camel {{ }} property placeholder syntax -->
       <transform>
+        <!-- call the method on the bean -->
         <method ref="myBean" method="saySomething"/>
       </transform>
       <filter>
@@ -35,6 +43,7 @@
       </filter>
       <to uri="stream:out"/>
     </route>
+
   </camelContext>
 
 </beans>