Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id B8C2A200CE0 for ; Wed, 5 Jul 2017 09:28:37 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id B7D5D162929; Wed, 5 Jul 2017 07:28:37 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 02166162924 for ; Wed, 5 Jul 2017 09:28:36 +0200 (CEST) Received: (qmail 29284 invoked by uid 500); 5 Jul 2017 07:28:36 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 29214 invoked by uid 99); 5 Jul 2017 07:28:36 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Jul 2017 07:28:36 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E02BAEE68A; Wed, 5 Jul 2017 07:28:34 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davsclaus@apache.org To: commits@camel.apache.org Date: Wed, 05 Jul 2017 07:28:38 -0000 Message-Id: <8b5960cf7e64435fa8f800e9d44ba211@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [5/8] camel git commit: CAMEL-11321: camel-spring-boot should lazy create ProducerTemplate and ConsumerTemplate so they are only created if really in use. archived-at: Wed, 05 Jul 2017 07:28:37 -0000 CAMEL-11321: camel-spring-boot should lazy create ProducerTemplate and ConsumerTemplate so they are only created if really in use. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/dcfb01ad Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/dcfb01ad Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/dcfb01ad Branch: refs/heads/master Commit: dcfb01adfa0b713e8b7fda8bdf8bb38cddf3a690 Parents: 253b99c Author: Claus Ibsen Authored: Tue Jul 4 14:25:57 2017 +0200 Committer: Claus Ibsen Committed: Wed Jul 5 09:28:22 2017 +0200 ---------------------------------------------------------------------- .../apache/camel/component/properties/PropertiesComponent.java | 4 ++-- .../org/apache/camel/spring/boot/CamelAutoConfiguration.java | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/dcfb01ad/camel-core/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java b/camel-core/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java index d3ba396..b26cdac 100644 --- a/camel-core/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java +++ b/camel-core/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java @@ -185,7 +185,7 @@ public class PropertiesComponent extends UriEndpointComponent { Properties prop = new Properties(); // use initial properties - if (null != initialProperties) { + if (initialProperties != null) { prop.putAll(initialProperties); } @@ -590,7 +590,7 @@ public class PropertiesComponent extends UriEndpointComponent { @Override public int hashCode() { - return locations != null ? locations.hashCode() : 0; + return locations.hashCode(); } @Override http://git-wip-us.apache.org/repos/asf/camel/blob/dcfb01ad/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 2c9f53d..690c632 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 @@ -64,6 +64,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; +import org.springframework.context.annotation.Lazy; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.Environment; import org.springframework.core.env.MutablePropertySources; @@ -224,6 +225,7 @@ public class CamelAutoConfiguration { /** * Default producer template for the bootstrapped Camel context. + * Create the bean lazy as it should only be created if its in-use. */ // We explicitly declare the destroyMethod to be "" as the Spring @Bean // annotation defaults to AbstractBeanDefinition.INFER_METHOD otherwise @@ -232,6 +234,7 @@ public class CamelAutoConfiguration { // lifecycle. @Bean(destroyMethod = "") @ConditionalOnMissingBean(ProducerTemplate.class) + @Lazy ProducerTemplate producerTemplate(CamelContext camelContext, CamelConfigurationProperties config) throws Exception { final ProducerTemplate producerTemplate = camelContext.createProducerTemplate(config.getProducerTemplateCacheSize()); @@ -242,6 +245,7 @@ public class CamelAutoConfiguration { /** * Default consumer template for the bootstrapped Camel context. + * Create the bean lazy as it should only be created if its in-use. */ // We explicitly declare the destroyMethod to be "" as the Spring @Bean // annotation defaults to AbstractBeanDefinition.INFER_METHOD otherwise @@ -250,6 +254,7 @@ public class CamelAutoConfiguration { // lifecycle. @Bean(destroyMethod = "") @ConditionalOnMissingBean(ConsumerTemplate.class) + @Lazy ConsumerTemplate consumerTemplate(CamelContext camelContext, CamelConfigurationProperties config) throws Exception { final ConsumerTemplate consumerTemplate = camelContext.createConsumerTemplate(config.getConsumerTemplateCacheSize());