camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hekon...@apache.org
Subject git commit: [CAMEL-7963] Added CamelConfigurationProperties.
Date Mon, 27 Oct 2014 11:56:38 GMT
Repository: camel
Updated Branches:
  refs/heads/master ad7fff5c1 -> ef039d532


[CAMEL-7963] Added CamelConfigurationProperties.


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

Branch: refs/heads/master
Commit: ef039d53219360ab66b6a78613e93b7107e440de
Parents: ad7fff5
Author: Henryk Konsek <hekonsek@gmail.com>
Authored: Mon Oct 27 12:56:27 2014 +0100
Committer: Henryk Konsek <hekonsek@gmail.com>
Committed: Mon Oct 27 12:56:27 2014 +0100

----------------------------------------------------------------------
 .../spring/boot/CamelAutoConfiguration.java     |  9 +++-
 .../boot/CamelConfigurationProperties.java      | 44 ++++++++++++++++++++
 .../spring/boot/CamelAutoConfigurationTest.java |  7 ++++
 3 files changed, 58 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ef039d53/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 ba42f25..068dcc7 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
@@ -25,6 +25,7 @@ import org.apache.camel.component.properties.PropertiesComponent;
 import org.apache.camel.component.properties.PropertiesParser;
 import org.apache.camel.spring.SpringCamelContext;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -101,9 +102,13 @@ import org.springframework.context.annotation.Configuration;
  * </p>
  */
 @Configuration
+@EnableConfigurationProperties(CamelConfigurationProperties.class)
 public class CamelAutoConfiguration {
 
     @Autowired
+    private CamelConfigurationProperties configurationProperties;
+
+    @Autowired
     private ApplicationContext applicationContext;
 
     @Autowired(required = false)
@@ -129,7 +134,7 @@ public class CamelAutoConfiguration {
      */
     @Bean
     ProducerTemplate producerTemplate() throws Exception {
-        return camelContext().createProducerTemplate();
+        return camelContext().createProducerTemplate(configurationProperties.getProducerTemplateCacheSize());
     }
 
     /**
@@ -137,7 +142,7 @@ public class CamelAutoConfiguration {
      */
     @Bean
     ConsumerTemplate consumerTemplate() throws Exception {
-        return camelContext().createConsumerTemplate();
+        return camelContext().createConsumerTemplate(configurationProperties.getConsumerTemplateCacheSize());
     }
 
     @Bean

http://git-wip-us.apache.org/repos/asf/camel/blob/ef039d53/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
new file mode 100644
index 0000000..e8f904e
--- /dev/null
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java
@@ -0,0 +1,44 @@
+/**
+ * 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;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+@ConfigurationProperties(prefix = "camel.springboot")
+public class CamelConfigurationProperties {
+
+    private int producerTemplateCacheSize = 1000;
+
+    private int consumerTemplateCacheSize = 1000;
+
+    public int getProducerTemplateCacheSize() {
+        return producerTemplateCacheSize;
+    }
+
+    public void setProducerTemplateCacheSize(int producerTemplateCacheSize) {
+        this.producerTemplateCacheSize = producerTemplateCacheSize;
+    }
+
+    public int getConsumerTemplateCacheSize() {
+        return consumerTemplateCacheSize;
+    }
+
+    public void setConsumerTemplateCacheSize(int consumerTemplateCacheSize) {
+        this.consumerTemplateCacheSize = consumerTemplateCacheSize;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ef039d53/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 eb27aa8..5d0b9f5 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
@@ -27,6 +27,7 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.IntegrationTest;
 import org.springframework.boot.test.SpringApplicationConfiguration;
 import org.springframework.context.annotation.Bean;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -34,6 +35,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 @RunWith(SpringJUnit4ClassRunner.class)
 @EnableAutoConfiguration
 @SpringApplicationConfiguration(classes = CamelAutoConfigurationTest.class)
+@IntegrationTest("camel.springboot.consumerTemplateCacheSize:100")
 public class CamelAutoConfigurationTest extends Assert {
 
     // Collaborators fixtures
@@ -91,6 +93,11 @@ public class CamelAutoConfigurationTest extends Assert {
     }
 
     @Test
+    public void shouldLoadConsumerTemplateWithSizeFromProperties() {
+        assertEquals(100, consumerTemplate.getMaximumCacheSize());
+    }
+
+    @Test
     public void shouldSendAndReceiveMessageWithTemplates() {
         // Given
         String message = "message";


Mime
View raw message