You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2021/11/23 13:19:44 UTC
[camel-spring-boot] 01/02: CAMEL-17220: Upgrade to spring boot 2.6.0
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git
commit 514685a16a9a4711797f6ef773654294f37dcce6
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Nov 23 14:10:16 2021 +0100
CAMEL-17220: Upgrade to spring boot 2.6.0
---
.../xml/SpringBootXmlCamelContextConfigurer.java | 23 +++++++++++++++-------
pom.xml | 2 +-
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/core/camel-spring-boot-xml/src/main/java/org/apache/camel/spring/boot/xml/SpringBootXmlCamelContextConfigurer.java b/core/camel-spring-boot-xml/src/main/java/org/apache/camel/spring/boot/xml/SpringBootXmlCamelContextConfigurer.java
index 35d3b62..9a71b8b 100644
--- a/core/camel-spring-boot-xml/src/main/java/org/apache/camel/spring/boot/xml/SpringBootXmlCamelContextConfigurer.java
+++ b/core/camel-spring-boot-xml/src/main/java/org/apache/camel/spring/boot/xml/SpringBootXmlCamelContextConfigurer.java
@@ -17,13 +17,17 @@
package org.apache.camel.spring.boot.xml;
import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.impl.engine.DefaultInjector;
+import org.apache.camel.spi.Injector;
import org.apache.camel.spring.SpringCamelContext;
import org.apache.camel.spring.boot.CamelAutoConfiguration;
import org.apache.camel.spring.boot.CamelConfigurationProperties;
+import org.apache.camel.spring.spi.SpringInjector;
import org.apache.camel.spring.xml.XmlCamelContextConfigurer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
+import org.springframework.context.ConfigurableApplicationContext;
/**
* Used to merge Camel Spring Boot configuration with {@link org.apache.camel.CamelContext} that
@@ -37,13 +41,18 @@ public class SpringBootXmlCamelContextConfigurer implements XmlCamelContextConfi
@Override
public void configure(ApplicationContext applicationContext, SpringCamelContext camelContext) {
CamelConfigurationProperties config = applicationContext.getBean(CamelConfigurationProperties.class);
- if (config != null) {
- try {
- LOG.debug("Merging XML based CamelContext with Spring Boot configuration properties");
- CamelAutoConfiguration.doConfigureCamelContext(applicationContext, camelContext, config);
- } catch (Exception e) {
- throw RuntimeCamelException.wrapRuntimeCamelException(e);
- }
+ Injector injector = camelContext.getInjector();
+ try {
+ LOG.debug("Merging XML based CamelContext with Spring Boot configuration properties");
+ // spring boot is not capable at this phase to use an injector that is creating beans
+ // via spring-boot itself, so use a default injector instead
+ camelContext.setInjector(new DefaultInjector(camelContext));
+ CamelAutoConfiguration.doConfigureCamelContext(applicationContext, camelContext, config);
+ } catch (Exception e) {
+ throw RuntimeCamelException.wrapRuntimeCamelException(e);
+ } finally {
+ // restore original injector
+ camelContext.setInjector(injector);
}
}
}
diff --git a/pom.xml b/pom.xml
index e6da831..39d2c2f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -108,7 +108,7 @@
<compiler.fork>false</compiler.fork>
<!-- Spring-Boot target version -->
- <spring-boot-version>2.5.7</spring-boot-version>
+ <spring-boot-version>2.6.0</spring-boot-version>
<!-- Camel target version -->
<camel-version>3.14.0-SNAPSHOT</camel-version>