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:24 UTC
[01/12] camel git commit: CAMEL-9161 Modify log message.
Repository: camel
Updated Branches:
refs/heads/camel-2.15.x 71af84504 -> 27a9b3953
refs/heads/camel-2.16.x 4404144ae -> 7f961480a
refs/heads/master 9209bab5a -> ba84da4ab
CAMEL-9161 Modify log message.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/329b53b9
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/329b53b9
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/329b53b9
Branch: refs/heads/master
Commit: 329b53b94d6d4e86c1579799cfe5d066cf585627
Parents: 8c27982
Author: Nick Stuart <ni...@portlandwebworks.com>
Authored: Tue Nov 10 12:03:56 2015 -0500
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Nov 11 08:12:38 2015 +0100
----------------------------------------------------------------------
.../main/java/org/apache/camel/spring/boot/RoutesCollector.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/329b53b9/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 b2fcd77..49e39c4 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
@@ -82,7 +82,7 @@ public class RoutesCollector implements ApplicationListener<ContextRefreshedEven
throw new CamelSpringBootInitializationException(e);
}
} else {
- LOG.debug("Not at root context - defer adding routes");
+ LOG.debug("Camel already started, not adding routes.");
}
}
[12/12] camel git commit: Fixed CS
Posted by da...@apache.org.
Fixed CS
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/27a9b395
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/27a9b395
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/27a9b395
Branch: refs/heads/camel-2.15.x
Commit: 27a9b3953c3647f70cf5a189833089578d5fc6ef
Parents: 0711eda
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Nov 11 08:18:22 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Nov 11 08:19:48 2015 +0100
----------------------------------------------------------------------
.../java/org/apache/camel/spring/boot/RoutesCollector.java | 2 +-
.../spring/boot/parent/SpringBootRefreshContextTest.java | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/27a9b395/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 2d164cd..51cc984 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
@@ -52,7 +52,7 @@ public class RoutesCollector implements ApplicationListener<ContextRefreshedEven
@Override
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
ApplicationContext applicationContext = contextRefreshedEvent.getApplicationContext();
- CamelContext camelContext = contextRefreshedEvent.getApplicationContext().getBean(CamelContext.class);
+ 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());
http://git-wip-us.apache.org/repos/asf/camel/blob/27a9b395/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
index dd2dc3b..d1adfcf 100644
--- a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
+++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
@@ -33,10 +33,10 @@ public class SpringBootRefreshContextTest {
public void shouldOnlyCollectRoutesOnce() {
GenericApplicationContext parent = new GenericApplicationContext();
parent.refresh();
- ConfigurableApplicationContext context = new SpringApplicationBuilder(Configuration.class).web(false).parent(parent).run();
- ContextRefreshedEvent refreshEvent = new ContextRefreshedEvent(context);
- RoutesCollector collector = context.getBean(RoutesCollector.class);
- collector.onApplicationEvent(refreshEvent); //no changes should happen here
+ ConfigurableApplicationContext context = new SpringApplicationBuilder(Configuration.class).web(false).parent(parent).run();
+ ContextRefreshedEvent refreshEvent = new ContextRefreshedEvent(context);
+ RoutesCollector collector = context.getBean(RoutesCollector.class);
+ collector.onApplicationEvent(refreshEvent); //no changes should happen here
}
}
[06/12] camel git commit: CAMEL-9161 Modify log message.
Posted by da...@apache.org.
CAMEL-9161 Modify log message.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/91fa3ec7
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/91fa3ec7
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/91fa3ec7
Branch: refs/heads/camel-2.16.x
Commit: 91fa3ec740aec4ba1ef2312f8d9dd4d90085e67b
Parents: 9c87aed
Author: Nick Stuart <ni...@portlandwebworks.com>
Authored: Tue Nov 10 12:03:56 2015 -0500
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Nov 11 08:19:01 2015 +0100
----------------------------------------------------------------------
.../main/java/org/apache/camel/spring/boot/RoutesCollector.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/91fa3ec7/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 b2fcd77..49e39c4 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
@@ -82,7 +82,7 @@ public class RoutesCollector implements ApplicationListener<ContextRefreshedEven
throw new CamelSpringBootInitializationException(e);
}
} else {
- LOG.debug("Not at root context - defer adding routes");
+ LOG.debug("Camel already started, not adding routes.");
}
}
[11/12] camel git commit: Polished. Fixes #674
Posted by da...@apache.org.
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);
}
}
[09/12] camel git commit: CAMEL-9161 Change for dealing with parent
contexts
Posted by da...@apache.org.
CAMEL-9161 Change for dealing with parent contexts
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/cc6d569f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/cc6d569f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/cc6d569f
Branch: refs/heads/camel-2.15.x
Commit: cc6d569fe049828e5d79bbfdc62a29b85ae92157
Parents: 71af845
Author: Nick Stuart <ni...@portlandwebworks.com>
Authored: Tue Nov 10 09:19:07 2015 -0500
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Nov 11 08:19:29 2015 +0100
----------------------------------------------------------------------
.../camel/spring/boot/RoutesCollector.java | 5 +-
.../parent/SpringBootRefreshContextTest.java | 57 ++++++++++++++++++++
.../parent/SpringBootWithParentContextTest.java | 51 ------------------
3 files changed, 60 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/cc6d569f/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 2b0a050..4aaa05d 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
@@ -22,6 +22,7 @@ import java.util.List;
import org.apache.camel.CamelContext;
import org.apache.camel.RoutesBuilder;
+import org.apache.camel.ServiceStatus;
import org.apache.camel.model.RoutesDefinition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,8 +52,8 @@ public class RoutesCollector implements ApplicationListener<ContextRefreshedEven
@Override
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
ApplicationContext applicationContext = contextRefreshedEvent.getApplicationContext();
- if (applicationContext.getParent() == null) {
- CamelContext camelContext = contextRefreshedEvent.getApplicationContext().getBean(CamelContext.class);
+ CamelContext camelContext = contextRefreshedEvent.getApplicationContext().getBean(CamelContext.class);
+ if (camelContext.getStatus() == ServiceStatus.Stopped) {
LOG.debug("Post-processing CamelContext bean: {}", camelContext.getName());
for (RoutesBuilder routesBuilder : applicationContext.getBeansOfType(RoutesBuilder.class).values()) {
try {
http://git-wip-us.apache.org/repos/asf/camel/blob/cc6d569f/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
new file mode 100644
index 0000000..dd2dc3b
--- /dev/null
+++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.boot.parent;
+
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spring.boot.RoutesCollector;
+import org.junit.Test;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.context.support.GenericApplicationContext;
+
+public class SpringBootRefreshContextTest {
+
+ @Test
+ public void shouldOnlyCollectRoutesOnce() {
+ GenericApplicationContext parent = new GenericApplicationContext();
+ parent.refresh();
+ ConfigurableApplicationContext context = new SpringApplicationBuilder(Configuration.class).web(false).parent(parent).run();
+ ContextRefreshedEvent refreshEvent = new ContextRefreshedEvent(context);
+ RoutesCollector collector = context.getBean(RoutesCollector.class);
+ collector.onApplicationEvent(refreshEvent); //no changes should happen here
+ }
+
+}
+
+@SpringBootApplication
+class Configuration {
+
+ @Bean
+ RoutesBuilder routes() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("seda:test").to("mock:test");
+ }
+ };
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/cc6d569f/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootWithParentContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootWithParentContextTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootWithParentContextTest.java
deleted file mode 100644
index 6a1c16a..0000000
--- a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootWithParentContextTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.spring.boot.parent;
-
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.builder.SpringApplicationBuilder;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.support.GenericApplicationContext;
-
-public class SpringBootWithParentContextTest {
-
- @Test
- public void shouldCollectRoutesOnlyInRootContext() {
- GenericApplicationContext parent = new GenericApplicationContext();
- parent.refresh();
- new SpringApplicationBuilder(Configuration.class).web(false).parent(parent).run();
- }
-
-}
-
-@SpringBootApplication
-class Configuration {
-
- @Bean
- RoutesBuilder routes() {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("seda:test").to("mock:test");
- }
- };
- }
-
-}
\ No newline at end of file
[05/12] camel git commit: CAMEL-9161 Change for dealing with parent
contexts
Posted by da...@apache.org.
CAMEL-9161 Change for dealing with parent contexts
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9c87aed7
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9c87aed7
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9c87aed7
Branch: refs/heads/camel-2.16.x
Commit: 9c87aed7625b2280298e93f0c0f5a8e4d1937018
Parents: 4404144
Author: Nick Stuart <ni...@portlandwebworks.com>
Authored: Tue Nov 10 09:19:07 2015 -0500
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Nov 11 08:18:56 2015 +0100
----------------------------------------------------------------------
.../camel/spring/boot/RoutesCollector.java | 5 +-
.../parent/SpringBootRefreshContextTest.java | 57 ++++++++++++++++++++
.../parent/SpringBootWithParentContextTest.java | 51 ------------------
3 files changed, 60 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/9c87aed7/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 e5dc610..b2fcd77 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
@@ -22,6 +22,7 @@ import java.util.List;
import org.apache.camel.CamelContext;
import org.apache.camel.RoutesBuilder;
+import org.apache.camel.ServiceStatus;
import org.apache.camel.model.RoutesDefinition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -55,8 +56,8 @@ public class RoutesCollector implements ApplicationListener<ContextRefreshedEven
@Override
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
ApplicationContext applicationContext = contextRefreshedEvent.getApplicationContext();
- if (applicationContext.getParent() == null) {
- CamelContext camelContext = contextRefreshedEvent.getApplicationContext().getBean(CamelContext.class);
+ CamelContext camelContext = contextRefreshedEvent.getApplicationContext().getBean(CamelContext.class);
+ if (camelContext.getStatus() == ServiceStatus.Stopped) {
LOG.debug("Post-processing CamelContext bean: {}", camelContext.getName());
for (RoutesBuilder routesBuilder : applicationContext.getBeansOfType(RoutesBuilder.class).values()) {
try {
http://git-wip-us.apache.org/repos/asf/camel/blob/9c87aed7/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
new file mode 100644
index 0000000..dd2dc3b
--- /dev/null
+++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.boot.parent;
+
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spring.boot.RoutesCollector;
+import org.junit.Test;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.context.support.GenericApplicationContext;
+
+public class SpringBootRefreshContextTest {
+
+ @Test
+ public void shouldOnlyCollectRoutesOnce() {
+ GenericApplicationContext parent = new GenericApplicationContext();
+ parent.refresh();
+ ConfigurableApplicationContext context = new SpringApplicationBuilder(Configuration.class).web(false).parent(parent).run();
+ ContextRefreshedEvent refreshEvent = new ContextRefreshedEvent(context);
+ RoutesCollector collector = context.getBean(RoutesCollector.class);
+ collector.onApplicationEvent(refreshEvent); //no changes should happen here
+ }
+
+}
+
+@SpringBootApplication
+class Configuration {
+
+ @Bean
+ RoutesBuilder routes() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("seda:test").to("mock:test");
+ }
+ };
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/9c87aed7/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootWithParentContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootWithParentContextTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootWithParentContextTest.java
deleted file mode 100644
index 6a1c16a..0000000
--- a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootWithParentContextTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.spring.boot.parent;
-
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.builder.SpringApplicationBuilder;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.support.GenericApplicationContext;
-
-public class SpringBootWithParentContextTest {
-
- @Test
- public void shouldCollectRoutesOnlyInRootContext() {
- GenericApplicationContext parent = new GenericApplicationContext();
- parent.refresh();
- new SpringApplicationBuilder(Configuration.class).web(false).parent(parent).run();
- }
-
-}
-
-@SpringBootApplication
-class Configuration {
-
- @Bean
- RoutesBuilder routes() {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("seda:test").to("mock:test");
- }
- };
- }
-
-}
\ No newline at end of file
[03/12] camel git commit: Polished. Fixes #674
Posted by da...@apache.org.
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);
}
}
[04/12] camel git commit: Fixed CS
Posted by da...@apache.org.
Fixed CS
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ba84da4a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ba84da4a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ba84da4a
Branch: refs/heads/master
Commit: ba84da4aba0a7d0cb185b95f3049adf9842ed5fc
Parents: e0baf2b
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Nov 11 08:18:22 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Nov 11 08:18:22 2015 +0100
----------------------------------------------------------------------
.../java/org/apache/camel/spring/boot/RoutesCollector.java | 2 +-
.../spring/boot/parent/SpringBootRefreshContextTest.java | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/ba84da4a/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 e864707..33d479b 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
@@ -56,7 +56,7 @@ public class RoutesCollector implements ApplicationListener<ContextRefreshedEven
@Override
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
ApplicationContext applicationContext = contextRefreshedEvent.getApplicationContext();
- CamelContext camelContext = contextRefreshedEvent.getApplicationContext().getBean(CamelContext.class);
+ 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());
http://git-wip-us.apache.org/repos/asf/camel/blob/ba84da4a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
index dd2dc3b..d1adfcf 100644
--- a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
+++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
@@ -33,10 +33,10 @@ public class SpringBootRefreshContextTest {
public void shouldOnlyCollectRoutesOnce() {
GenericApplicationContext parent = new GenericApplicationContext();
parent.refresh();
- ConfigurableApplicationContext context = new SpringApplicationBuilder(Configuration.class).web(false).parent(parent).run();
- ContextRefreshedEvent refreshEvent = new ContextRefreshedEvent(context);
- RoutesCollector collector = context.getBean(RoutesCollector.class);
- collector.onApplicationEvent(refreshEvent); //no changes should happen here
+ ConfigurableApplicationContext context = new SpringApplicationBuilder(Configuration.class).web(false).parent(parent).run();
+ ContextRefreshedEvent refreshEvent = new ContextRefreshedEvent(context);
+ RoutesCollector collector = context.getBean(RoutesCollector.class);
+ collector.onApplicationEvent(refreshEvent); //no changes should happen here
}
}
[10/12] camel git commit: CAMEL-9161 Modify log message.
Posted by da...@apache.org.
CAMEL-9161 Modify log message.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/faea2ad8
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/faea2ad8
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/faea2ad8
Branch: refs/heads/camel-2.15.x
Commit: faea2ad8cda2f027540843d687f8c2a2a1424996
Parents: cc6d569
Author: Nick Stuart <ni...@portlandwebworks.com>
Authored: Tue Nov 10 12:03:56 2015 -0500
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Nov 11 08:19:36 2015 +0100
----------------------------------------------------------------------
.../main/java/org/apache/camel/spring/boot/RoutesCollector.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/faea2ad8/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 4aaa05d..52c9525 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
@@ -78,7 +78,7 @@ public class RoutesCollector implements ApplicationListener<ContextRefreshedEven
throw new CamelSpringBootInitializationException(e);
}
} else {
- LOG.debug("Not at root context - defer adding routes");
+ LOG.debug("Camel already started, not adding routes.");
}
}
[07/12] camel git commit: Polished. Fixes #674
Posted by da...@apache.org.
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);
}
}
[08/12] camel git commit: Fixed CS
Posted by da...@apache.org.
Fixed CS
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7f961480
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7f961480
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7f961480
Branch: refs/heads/camel-2.16.x
Commit: 7f961480a2be5175d3ca7d883f72f701477dd800
Parents: 5d43573
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Nov 11 08:18:22 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Nov 11 08:19:11 2015 +0100
----------------------------------------------------------------------
.../java/org/apache/camel/spring/boot/RoutesCollector.java | 2 +-
.../spring/boot/parent/SpringBootRefreshContextTest.java | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/7f961480/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 e864707..33d479b 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
@@ -56,7 +56,7 @@ public class RoutesCollector implements ApplicationListener<ContextRefreshedEven
@Override
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
ApplicationContext applicationContext = contextRefreshedEvent.getApplicationContext();
- CamelContext camelContext = contextRefreshedEvent.getApplicationContext().getBean(CamelContext.class);
+ 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());
http://git-wip-us.apache.org/repos/asf/camel/blob/7f961480/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
index dd2dc3b..d1adfcf 100644
--- a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
+++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
@@ -33,10 +33,10 @@ public class SpringBootRefreshContextTest {
public void shouldOnlyCollectRoutesOnce() {
GenericApplicationContext parent = new GenericApplicationContext();
parent.refresh();
- ConfigurableApplicationContext context = new SpringApplicationBuilder(Configuration.class).web(false).parent(parent).run();
- ContextRefreshedEvent refreshEvent = new ContextRefreshedEvent(context);
- RoutesCollector collector = context.getBean(RoutesCollector.class);
- collector.onApplicationEvent(refreshEvent); //no changes should happen here
+ ConfigurableApplicationContext context = new SpringApplicationBuilder(Configuration.class).web(false).parent(parent).run();
+ ContextRefreshedEvent refreshEvent = new ContextRefreshedEvent(context);
+ RoutesCollector collector = context.getBean(RoutesCollector.class);
+ collector.onApplicationEvent(refreshEvent); //no changes should happen here
}
}
[02/12] camel git commit: CAMEL-9161 Change for dealing with parent
contexts
Posted by da...@apache.org.
CAMEL-9161 Change for dealing with parent contexts
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8c279828
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8c279828
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8c279828
Branch: refs/heads/master
Commit: 8c27982893033dc59a2aa64ac14bac8016e4b8b6
Parents: 9209bab
Author: Nick Stuart <ni...@portlandwebworks.com>
Authored: Tue Nov 10 09:19:07 2015 -0500
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Nov 11 08:12:38 2015 +0100
----------------------------------------------------------------------
.../camel/spring/boot/RoutesCollector.java | 5 +-
.../parent/SpringBootRefreshContextTest.java | 57 ++++++++++++++++++++
.../parent/SpringBootWithParentContextTest.java | 51 ------------------
3 files changed, 60 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/8c279828/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 e5dc610..b2fcd77 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
@@ -22,6 +22,7 @@ import java.util.List;
import org.apache.camel.CamelContext;
import org.apache.camel.RoutesBuilder;
+import org.apache.camel.ServiceStatus;
import org.apache.camel.model.RoutesDefinition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -55,8 +56,8 @@ public class RoutesCollector implements ApplicationListener<ContextRefreshedEven
@Override
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
ApplicationContext applicationContext = contextRefreshedEvent.getApplicationContext();
- if (applicationContext.getParent() == null) {
- CamelContext camelContext = contextRefreshedEvent.getApplicationContext().getBean(CamelContext.class);
+ CamelContext camelContext = contextRefreshedEvent.getApplicationContext().getBean(CamelContext.class);
+ if (camelContext.getStatus() == ServiceStatus.Stopped) {
LOG.debug("Post-processing CamelContext bean: {}", camelContext.getName());
for (RoutesBuilder routesBuilder : applicationContext.getBeansOfType(RoutesBuilder.class).values()) {
try {
http://git-wip-us.apache.org/repos/asf/camel/blob/8c279828/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
new file mode 100644
index 0000000..dd2dc3b
--- /dev/null
+++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.boot.parent;
+
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spring.boot.RoutesCollector;
+import org.junit.Test;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.context.support.GenericApplicationContext;
+
+public class SpringBootRefreshContextTest {
+
+ @Test
+ public void shouldOnlyCollectRoutesOnce() {
+ GenericApplicationContext parent = new GenericApplicationContext();
+ parent.refresh();
+ ConfigurableApplicationContext context = new SpringApplicationBuilder(Configuration.class).web(false).parent(parent).run();
+ ContextRefreshedEvent refreshEvent = new ContextRefreshedEvent(context);
+ RoutesCollector collector = context.getBean(RoutesCollector.class);
+ collector.onApplicationEvent(refreshEvent); //no changes should happen here
+ }
+
+}
+
+@SpringBootApplication
+class Configuration {
+
+ @Bean
+ RoutesBuilder routes() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("seda:test").to("mock:test");
+ }
+ };
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/8c279828/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootWithParentContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootWithParentContextTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootWithParentContextTest.java
deleted file mode 100644
index 6a1c16a..0000000
--- a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/parent/SpringBootWithParentContextTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.spring.boot.parent;
-
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.builder.SpringApplicationBuilder;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.support.GenericApplicationContext;
-
-public class SpringBootWithParentContextTest {
-
- @Test
- public void shouldCollectRoutesOnlyInRootContext() {
- GenericApplicationContext parent = new GenericApplicationContext();
- parent.refresh();
- new SpringApplicationBuilder(Configuration.class).web(false).parent(parent).run();
- }
-
-}
-
-@SpringBootApplication
-class Configuration {
-
- @Bean
- RoutesBuilder routes() {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("seda:test").to("mock:test");
- }
- };
- }
-
-}
\ No newline at end of file