Camel Spring Javaconfig should also ioc producer/consumer template as spring-boot does.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3343aec8 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3343aec8 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3343aec8 Branch: refs/heads/master Commit: 3343aec81a45763bbd3b46ec3646b217948689eb Parents: 74748d9 Author: Claus Ibsen <[email protected]> Authored: Mon Mar 28 14:35:48 2016 +0200 Committer: Claus Ibsen <[email protected]> Committed: Mon Mar 28 14:35:48 2016 +0200 ---------------------------------------------------------------------- .../spring/javaconfig/CamelConfiguration.java | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/3343aec8/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/CamelConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/CamelConfiguration.java b/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/CamelConfiguration.java index d8aaf23..2df05da 100644 --- a/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/CamelConfiguration.java +++ b/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/CamelConfiguration.java @@ -19,9 +19,12 @@ package org.apache.camel.spring.javaconfig; import java.util.ArrayList; import java.util.List; import java.util.Map; + import static java.util.Collections.emptyList; import org.apache.camel.CamelContext; +import org.apache.camel.ConsumerTemplate; +import org.apache.camel.ProducerTemplate; import org.apache.camel.RoutesBuilder; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.spring.CamelBeanPostProcessor; @@ -123,6 +126,24 @@ public abstract class CamelConfiguration implements BeanFactoryAware, Applicatio return configuredObject; } + /** + * Get's the {@link ProducerTemplate} to be used. + */ + @Bean(initMethod = "", destroyMethod = "") + // Camel handles the lifecycle of this bean + public ProducerTemplate producerTemplate(CamelContext camelContext) throws Exception { + return camelContext.createProducerTemplate(); + } + + /** + * Get's the {@link ConsumerTemplate} to be used. + */ + @Bean(initMethod = "", destroyMethod = "") + // Camel handles the lifecycle of this bean + public ConsumerTemplate consumerTemplate(CamelContext camelContext) throws Exception { + return camelContext.createConsumerTemplate(); + } + @Bean public CamelBeanPostProcessor camelBeanPostProcessor() throws Exception { CamelBeanPostProcessor answer = new CamelBeanPostProcessor();
