This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git
The following commit(s) were added to refs/heads/master by this push:
new ec40548 CAMEL-16235: camel-servlet-starter does not auto create Camel
ServletComponent
ec40548 is described below
commit ec40548f988239e7a490cbe12ef4d64cf6610783
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Mar 17 11:50:56 2021 +0100
CAMEL-16235: camel-servlet-starter does not auto create Camel
ServletComponent
---
.../springboot/ServletMappingAutoConfiguration.java | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git
a/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletMappingAutoConfiguration.java
b/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletMappingAutoConfiguration.java
index 00fba5c..2e6f74c 100644
---
a/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletMappingAutoConfiguration.java
+++
b/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletMappingAutoConfiguration.java
@@ -16,15 +16,19 @@
*/
package org.apache.camel.component.servlet.springboot;
+import org.apache.camel.CamelContext;
import org.apache.camel.component.servlet.CamelHttpTransportServlet;
+import org.apache.camel.component.servlet.ServletComponent;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import
org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Lazy;
/**
* Servlet mapping auto-configuration.
@@ -48,4 +52,16 @@ public class ServletMappingAutoConfiguration {
return mapping;
}
+ /**
+ * Ensures the Camel Servlet component is automatic created if no custom
exists.
+ */
+ @Lazy
+ @Bean(name = "servlet-component")
+ @ConditionalOnMissingBean(ServletComponent.class)
+ public ServletComponent configureServletComponent(CamelContext
camelContext) throws Exception {
+ ServletComponent component = new ServletComponent();
+ component.setCamelContext(camelContext);
+ return component;
+ }
+
}