Repository: camel Updated Branches: refs/heads/master 654c33aab -> 36895c7b8
CAMEL-8295 Add Name for Camel Context in camel-spring-boot Configuration Properties. Its required to set the Camel Context Name before run the RouteBuilder. After the RouteBuilder ran, can't change the Camel Context Name fully in all JMX Management Beans. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f2fba4f1 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f2fba4f1 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f2fba4f1 Branch: refs/heads/master Commit: f2fba4f1914191fb7be30365c78e4a017780d2f6 Parents: 654c33a Author: eddi888 <edgar.wentzl...@gmx.net> Authored: Thu Jan 29 12:33:15 2015 +0100 Committer: eddi888 <edgar.wentzl...@gmx.net> Committed: Thu Jan 29 12:33:15 2015 +0100 ---------------------------------------------------------------------- .../spring/boot/CamelAutoConfiguration.java | 4 ++++ .../boot/CamelConfigurationProperties.java | 13 +++++++++++++ .../spring/boot/CamelAutoConfigurationTest.java | 20 ++++---------------- 3 files changed, 21 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/f2fba4f1/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java index 7210f87..b4f225e 100644 --- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java +++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java @@ -51,6 +51,10 @@ public class CamelAutoConfiguration { camelContext.disableJMX(); } + if (configurationProperties.getName()!=null) { + ((SpringCamelContext) camelContext).setName(configurationProperties.getName()); + } + return camelContext; } http://git-wip-us.apache.org/repos/asf/camel/blob/f2fba4f1/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java index 51bb2b0..a036e6d 100644 --- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java +++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java @@ -43,6 +43,11 @@ public class CamelConfigurationProperties { */ private boolean typeConversion = true; + /** + * Sets the name of the this CamelContext. + */ + private String name = null; + // Getters & setters public boolean isJmxEnabled() { @@ -77,4 +82,12 @@ public class CamelConfigurationProperties { this.typeConversion = typeConversion; } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } http://git-wip-us.apache.org/repos/asf/camel/blob/f2fba4f1/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/CamelAutoConfigurationTest.java ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/CamelAutoConfigurationTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/CamelAutoConfigurationTest.java index 50595fa..970ed8d 100644 --- a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/CamelAutoConfigurationTest.java +++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/CamelAutoConfigurationTest.java @@ -34,7 +34,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import static org.apache.camel.spring.boot.TestConfig.CONTEXT_NAME; import static org.apache.camel.spring.boot.TestConfig.ROUTE_ID; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -44,7 +43,8 @@ import static org.mockito.Mockito.verify; @SpringApplicationConfiguration(classes = {TestConfig.class, CamelAutoConfigurationTest.class, RouteConfigWithCamelContextInjected.class}) @IntegrationTest({ "camel.springboot.consumerTemplateCacheSize=100", - "camel.springboot.jmxEnabled=false"}) + "camel.springboot.jmxEnabled=true", + "camel.springboot.name=customName"}) public class CamelAutoConfigurationTest extends Assert { // Collaborators fixtures @@ -132,7 +132,8 @@ public class CamelAutoConfigurationTest extends Assert { @Test public void shouldChangeContextNameViaConfigurationCallback() { - assertEquals(CONTEXT_NAME, camelContext.getName()); + assertEquals("customName", camelContext.getName()); + assertEquals(camelContext.getName(), camelContext.getManagementName()); } @Test @@ -157,8 +158,6 @@ class TestConfig { static final String ROUTE_ID = "testRoute"; - static final String CONTEXT_NAME = "customName"; - // Test beans @Bean @@ -177,15 +176,4 @@ class TestConfig { return mock(CamelContextConfiguration.class); } - @Bean - CamelContextConfiguration nameConfiguration() { - return new CamelContextConfiguration() { - @Override - public void beforeApplicationStart(CamelContext camelContext) { - SpringCamelContext springCamelContext = (SpringCamelContext) camelContext; - springCamelContext.setName(CONTEXT_NAME); - } - }; - } - } \ No newline at end of file