This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch CAMEL-13947 in repository https://gitbox.apache.org/repos/asf/camel.git
commit 094bf434db90500d8b4dc83fd467193020287c51 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Thu Sep 26 08:37:40 2019 +0200 CAMEL-13947: PropertiesComponent should be a static service and resolved like other similar features. --- .../camel/spring/boot/CamelAutoConfiguration.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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 afb6802..6a5bd55 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 @@ -84,13 +84,19 @@ public class CamelAutoConfiguration { } static CamelContext doConfigureCamelContext(ApplicationContext applicationContext, - CamelContext camelContext, - CamelConfigurationProperties config) throws Exception { + CamelContext camelContext, + CamelConfigurationProperties config) throws Exception { camelContext.init(); - final Map<String, BeanRepository> repositories = applicationContext.getBeansOfType(BeanRepository.class); + // initialize properties component eager + PropertiesComponent pc = applicationContext.getBeanProvider(PropertiesComponent.class).getIfAvailable(); + if (pc != null) { + pc.setCamelContext(camelContext); + camelContext.setPropertiesComponent(pc); + } + final Map<String, BeanRepository> repositories = applicationContext.getBeansOfType(BeanRepository.class); if (!repositories.isEmpty()) { List<BeanRepository> reps = new ArrayList<>(); // include default bean repository as well @@ -127,6 +133,7 @@ public class CamelAutoConfiguration { // lookup and configure SPI beans DefaultConfigurationConfigurer.afterPropertiesSet(camelContext); + return camelContext; } @@ -215,10 +222,8 @@ public class CamelAutoConfiguration { // (PropertiesComponent extends ServiceSupport) would be used for bean // destruction. And we want Camel to handle the lifecycle. @Bean(destroyMethod = "") - @Lazy - PropertiesComponent properties(CamelContext camelContext, PropertiesParser parser) { + PropertiesComponent properties(PropertiesParser parser) { PropertiesComponent pc = new PropertiesComponent(); - pc.setCamelContext(camelContext); pc.setPropertiesParser(parser); return pc; }