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 2015/11/11 08:16:26 UTC

[03/12] camel git commit: Polished. Fixes #674

Polished. Fixes #674


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

Branch: refs/heads/master
Commit: e0baf2b0961b2db0d8216fa83413c541693a50ea
Parents: 329b53b
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Nov 11 08:17:03 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Nov 11 08:17:03 2015 +0100

----------------------------------------------------------------------
 .../org/apache/camel/spring/boot/RoutesCollector.java | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e0baf2b0/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java
index 49e39c4..e864707 100644
--- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java
@@ -57,6 +57,7 @@ public class RoutesCollector implements ApplicationListener<ContextRefreshedEven
     public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
         ApplicationContext applicationContext = contextRefreshedEvent.getApplicationContext();
 		CamelContext camelContext = contextRefreshedEvent.getApplicationContext().getBean(CamelContext.class);
+        // if we have not yet started
         if (camelContext.getStatus() == ServiceStatus.Stopped) {
             LOG.debug("Post-processing CamelContext bean: {}", camelContext.getName());
             for (RoutesBuilder routesBuilder : applicationContext.getBeansOfType(RoutesBuilder.class).values()) {
@@ -64,19 +65,18 @@ public class RoutesCollector implements ApplicationListener<ContextRefreshedEven
                     LOG.debug("Injecting following route into the CamelContext: {}", routesBuilder);
                     camelContext.addRoutes(routesBuilder);
                 } catch (Exception e) {
-                    throw new RuntimeException(e);
+                    throw new CamelSpringBootInitializationException(e);
                 }
             }
 
-            loadXmlRoutes(applicationContext, camelContext);
+            try {
+                loadXmlRoutes(applicationContext, camelContext);
 
-            if (camelContextConfigurations != null) {
                 for (CamelContextConfiguration camelContextConfiguration : camelContextConfigurations) {
                     LOG.debug("CamelContextConfiguration found. Invoking: {}", camelContextConfiguration);
                     camelContextConfiguration.beforeApplicationStart(camelContext);
                 }
-            }
-            try {
+
                 camelContext.start();
             } catch (Exception e) {
                 throw new CamelSpringBootInitializationException(e);
@@ -88,7 +88,7 @@ public class RoutesCollector implements ApplicationListener<ContextRefreshedEven
 
     // Helpers
 
-    private void loadXmlRoutes(ApplicationContext applicationContext, CamelContext camelContext) {
+    private void loadXmlRoutes(ApplicationContext applicationContext, CamelContext camelContext) throws Exception {
         LOG.debug("Started XML routes detection. Scanning classpath (/camel/*.xml)...");
         try {
             Resource[] xmlRoutes = applicationContext.getResources("classpath:camel/*.xml");
@@ -98,8 +98,6 @@ public class RoutesCollector implements ApplicationListener<ContextRefreshedEven
             }
         } catch (FileNotFoundException e) {
             LOG.debug("No XMl routes found in the classpath (/camel/*.xml). Skipping XML routes detection.");
-        } catch (Exception e) {
-            throw new RuntimeException(e);
         }
     }