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:30 UTC
[07/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/5d43573b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5d43573b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5d43573b
Branch: refs/heads/camel-2.16.x
Commit: 5d43573bd1130945cc99bea2b43e182a6391b56a
Parents: 91fa3ec
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:06 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/5d43573b/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);
}
}