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:34 UTC
[11/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/0711eda9
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0711eda9
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0711eda9
Branch: refs/heads/camel-2.15.x
Commit: 0711eda94216fdf59b2f0fef3b54f830ea9313ba
Parents: faea2ad
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:19:42 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/0711eda9/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 52c9525..2d164cd 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
@@ -53,6 +53,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()) {
@@ -60,19 +61,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);
@@ -84,7 +84,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");
@@ -94,8 +94,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);
}
}