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 464934a CAMEL-14963: Route Template
464934a is described below
commit 464934ab8ab1e4c4726801e9e48319654b766bdf
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Jul 3 14:45:05 2020 +0200
CAMEL-14963: Route Template
---
.../src/main/docs/spring-boot.adoc | 3 +-
.../spring/boot/SpringBootRoutesCollector.java | 37 ++++++++++++++++++++--
docs/modules/ROOT/pages/spring-boot.adoc | 3 +-
3 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/core/camel-spring-boot/src/main/docs/spring-boot.adoc
b/core/camel-spring-boot/src/main/docs/spring-boot.adoc
index 2b7aa95..df7e8c6 100644
--- a/core/camel-spring-boot/src/main/docs/spring-boot.adoc
+++ b/core/camel-spring-boot/src/main/docs/spring-boot.adoc
@@ -92,7 +92,7 @@ When using spring-boot with Spring Boot make sure to use the
following Maven dep
----
-The component supports 148 options, which are listed below.
+The component supports 149 options, which are listed below.
@@ -224,6 +224,7 @@ The component supports 148 options, which are listed below.
| *camel.springboot.use-mdc-logging* | To turn on MDC logging | false | Boolean
| *camel.springboot.warn-on-early-shutdown* | Whether to log a WARN if Camel
on Spring Boot was immediately shutdown after starting which very likely is
because there is no JVM thread to keep the application running. | true | Boolean
| *camel.springboot.xml-rests* | Directory to scan for adding additional XML
rests. You can turn this off by setting the value to false. Files can be loaded
from either classpath or file by prefixing with classpath: or file: Wildcards
is supported using a ANT pattern style paths, such as
classpath:**/*camel*.xml Multiple directories can be specified
and separated by comma, such as:
file:/myapp/mycamel/*.xml,file:/myapp/myothercamel/*.xml |
classpath:camel-rest/*.x [...]
+| *camel.springboot.xml-route-templates* | | | String
| *camel.springboot.xml-routes* | Directory to scan for adding additional XML
routes. You can turn this off by setting the value to false. Files can be
loaded from either classpath or file by prefixing with classpath: or file:
Wildcards is supported using a ANT pattern style paths, such as
classpath:**/*camel*.xml Multiple directories can be specified
and separated by comma, such as:
file:/myapp/mycamel/*.xml,file:/myapp/myothercamel/*.xml |
classpath:camel/*.xml [...]
| *camel.ssl.cert-alias* | An optional certificate alias to use. This is
useful when the keystore has multiple certificates. | | String
| *camel.ssl.cipher-suites* | The optional explicitly configured cipher suites
for this configuration. | | CipherSuitesParameters
diff --git
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringBootRoutesCollector.java
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringBootRoutesCollector.java
index 6e310d3..d75d278 100644
---
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringBootRoutesCollector.java
+++
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringBootRoutesCollector.java
@@ -26,6 +26,7 @@ import org.apache.camel.ExtendedCamelContext;
import org.apache.camel.RoutesBuilder;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.main.DefaultRoutesCollector;
+import org.apache.camel.model.RouteTemplatesDefinition;
import org.apache.camel.model.RoutesDefinition;
import org.apache.camel.model.rest.RestsDefinition;
import org.apache.camel.spi.XMLRoutesDefinitionLoader;
@@ -125,7 +126,9 @@ public class SpringBootRoutesCollector extends
DefaultRoutesCollector {
ExtendedCamelContext extendedCamelContext =
camelContext.adapt(ExtendedCamelContext.class);
XMLRoutesDefinitionLoader xmlLoader =
extendedCamelContext.getXMLRoutesDefinitionLoader();
RoutesDefinition routes = (RoutesDefinition)
xmlLoader.loadRoutesDefinition(camelContext, xmlRoute.getInputStream());
- answer.add(routes);
+ if (routes != null) {
+ answer.add(routes);
+ }
}
} catch (FileNotFoundException e) {
log.debug("No XML routes found in {}. Skipping XML routes
detection.", part);
@@ -138,6 +141,34 @@ public class SpringBootRoutesCollector extends
DefaultRoutesCollector {
}
@Override
+ public List<RouteTemplatesDefinition>
collectXmlRouteTemplatesFromDirectory(CamelContext camelContext, String
directory) throws Exception {
+ List<RouteTemplatesDefinition> answer = new ArrayList<>();
+
+ String[] parts = directory.split(",");
+ for (String part : parts) {
+ log.info("Loading additional Camel XML route templates from: {}",
part);
+ try {
+ Resource[] xmlRouteTemplates =
applicationContext.getResources(part);
+ for (Resource xmlRoute : xmlRouteTemplates) {
+ log.debug("Found XML route template: {}", xmlRoute);
+ ExtendedCamelContext extendedCamelContext =
camelContext.adapt(ExtendedCamelContext.class);
+ XMLRoutesDefinitionLoader xmlLoader =
extendedCamelContext.getXMLRoutesDefinitionLoader();
+ RouteTemplatesDefinition templates =
(RouteTemplatesDefinition) xmlLoader.loadRouteTemplatesDefinition(camelContext,
xmlRoute.getInputStream());
+ if (templates != null) {
+ answer.add(templates);
+ }
+ }
+ } catch (FileNotFoundException e) {
+ log.debug("No XML route templates found in {}. Skipping XML
route templates detection.", part);
+ } catch (Exception e) {
+ throw RuntimeCamelException.wrapRuntimeException(e);
+ }
+ }
+
+ return answer;
+ }
+
+ @Override
public List<RestsDefinition> collectXmlRestsFromDirectory(CamelContext
camelContext, String directory) {
List<RestsDefinition> answer = new ArrayList<>();
@@ -150,7 +181,9 @@ public class SpringBootRoutesCollector extends
DefaultRoutesCollector {
ExtendedCamelContext extendedCamelContext =
camelContext.adapt(ExtendedCamelContext.class);
XMLRoutesDefinitionLoader xmlLoader =
extendedCamelContext.getXMLRoutesDefinitionLoader();
RestsDefinition rests = (RestsDefinition)
xmlLoader.loadRestsDefinition(camelContext, xmlRest.getInputStream());
- answer.add(rests);
+ if (rests != null) {
+ answer.add(rests);
+ }
}
} catch (FileNotFoundException e) {
log.debug("No XML rests found in {}. Skipping XML rests
detection.", part);
diff --git a/docs/modules/ROOT/pages/spring-boot.adoc
b/docs/modules/ROOT/pages/spring-boot.adoc
index 2b7aa95..df7e8c6 100644
--- a/docs/modules/ROOT/pages/spring-boot.adoc
+++ b/docs/modules/ROOT/pages/spring-boot.adoc
@@ -92,7 +92,7 @@ When using spring-boot with Spring Boot make sure to use the
following Maven dep
----
-The component supports 148 options, which are listed below.
+The component supports 149 options, which are listed below.
@@ -224,6 +224,7 @@ The component supports 148 options, which are listed below.
| *camel.springboot.use-mdc-logging* | To turn on MDC logging | false | Boolean
| *camel.springboot.warn-on-early-shutdown* | Whether to log a WARN if Camel
on Spring Boot was immediately shutdown after starting which very likely is
because there is no JVM thread to keep the application running. | true | Boolean
| *camel.springboot.xml-rests* | Directory to scan for adding additional XML
rests. You can turn this off by setting the value to false. Files can be loaded
from either classpath or file by prefixing with classpath: or file: Wildcards
is supported using a ANT pattern style paths, such as
classpath:**/*camel*.xml Multiple directories can be specified
and separated by comma, such as:
file:/myapp/mycamel/*.xml,file:/myapp/myothercamel/*.xml |
classpath:camel-rest/*.x [...]
+| *camel.springboot.xml-route-templates* | | | String
| *camel.springboot.xml-routes* | Directory to scan for adding additional XML
routes. You can turn this off by setting the value to false. Files can be
loaded from either classpath or file by prefixing with classpath: or file:
Wildcards is supported using a ANT pattern style paths, such as
classpath:**/*camel*.xml Multiple directories can be specified
and separated by comma, such as:
file:/myapp/mycamel/*.xml,file:/myapp/myothercamel/*.xml |
classpath:camel/*.xml [...]
| *camel.ssl.cert-alias* | An optional certificate alias to use. This is
useful when the keystore has multiple certificates. | | String
| *camel.ssl.cipher-suites* | The optional explicitly configured cipher suites
for this configuration. | | CipherSuitesParameters