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 2016/03/17 11:54:50 UTC

[3/3] camel git commit: CAMEL-9719: Camel Spring Boot Starter

CAMEL-9719: Camel Spring Boot Starter


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7c05e621
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7c05e621
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7c05e621

Branch: refs/heads/master
Commit: 7c05e621f4d48c0042062f82cbf5dec5201e72b9
Parents: 28c83d5
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Mar 17 11:49:34 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Mar 17 11:54:38 2016 +0100

----------------------------------------------------------------------
 .../src/main/java/sample/camel/SampleBean.java           |  7 +++++++
 .../main/java/sample/camel/SampleCamelApplication.java   | 11 ++++++++++-
 .../src/main/java/sample/camel/SampleCamelRouter.java    |  7 +++++++
 .../src/main/resources/application.properties            |  4 ----
 .../java/sample/camel/SampleCamelApplicationTest.java    |  2 ++
 5 files changed, 26 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7c05e621/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleBean.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleBean.java b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleBean.java
index 0161acf..ec7b3dd 100644
--- a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleBean.java
+++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleBean.java
@@ -19,6 +19,12 @@ 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 {
 
@@ -28,4 +34,5 @@ public class SampleBean {
     public String saySomething() {
         return say;
     }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/7c05e621/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java
index 8a68b69..e90caf3 100644
--- a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java
+++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java
@@ -19,10 +19,19 @@ package sample.camel;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.builder.SpringApplicationBuilder;
 
+/**
+ * A sample Spring Boot application that starts the Camel routes.
+ * <p/>
+ * See the <tt>application.properties</tt> where the
+ */
 @SpringBootApplication
 public class SampleCamelApplication {
 
+    /**
+     * A main method to start this application.
+     */
     public static void main(String[] args) {
-        new SpringApplicationBuilder().sources(SampleCamelApplication.class).run(args).registerShutdownHook();
+        new SpringApplicationBuilder().sources(SampleCamelApplication.class).run(args);
     }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/7c05e621/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java
index 5ce9cb7..4e0422e 100644
--- a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java
+++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java
@@ -17,7 +17,14 @@
 package sample.camel;
 
 import org.apache.camel.builder.RouteBuilder;
+import org.springframework.stereotype.Component;
 
+/**
+ * A simple Camel route that triggers from a timer and calls a bean and prints to system out.
+ * <p/>
+ * Use <tt>@Component</tt> to make Camel auto detect this route when starting.
+ */
+@Component
 public class SampleCamelRouter extends RouteBuilder {
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/7c05e621/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/resources/application.properties
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/resources/application.properties b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/resources/application.properties
index 9270963..ab11489 100644
--- a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/resources/application.properties
+++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/resources/application.properties
@@ -15,9 +15,6 @@
 # limitations under the License.
 #
 
-spring.main.sources: sample.camel.SampleCamelRouter
-
-
 # the name of Camel
 camel.springboot.name = SampleCamel
 
@@ -25,7 +22,6 @@ camel.springboot.name = SampleCamel
 camel.springboot.main-run-controller = true
 
 
-
 # properties used in the Camel route and beans
 # --------------------------------------------
 

http://git-wip-us.apache.org/repos/asf/camel/blob/7c05e621/components/camel-spring-boot-starter/camel-spring-boot-sample/src/test/java/sample/camel/SampleCamelApplicationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/test/java/sample/camel/SampleCamelApplicationTest.java b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/test/java/sample/camel/SampleCamelApplicationTest.java
index e5a097c..501f7ac 100644
--- a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/test/java/sample/camel/SampleCamelApplicationTest.java
+++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/test/java/sample/camel/SampleCamelApplicationTest.java
@@ -23,6 +23,7 @@ import org.apache.camel.builder.NotifyBuilder;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.IntegrationTest;
 import org.springframework.boot.test.SpringApplicationConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
@@ -30,6 +31,7 @@ import static org.junit.Assert.assertTrue;
 
 @RunWith(SpringJUnit4ClassRunner.class)
 @SpringApplicationConfiguration(SampleCamelApplication.class)
+@IntegrationTest("camel.springboot.main-run-controller=false")
 public class SampleCamelApplicationTest {
 
     @Autowired