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 2023/10/02 19:39:20 UTC
[camel] branch main updated: CAMEL-19806: camel-jbang - Load blueprint bean for list/map types
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.git
The following commit(s) were added to refs/heads/main by this push:
new 4313e68016c CAMEL-19806: camel-jbang - Load blueprint bean for list/map types
4313e68016c is described below
commit 4313e68016c6b755f6ce27f194f5f33ee999b4b4
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Oct 2 21:39:03 2023 +0200
CAMEL-19806: camel-jbang - Load blueprint bean for list/map types
---
.../xml/blueprint/BlueprintXmlBeansHandler.java | 35 ++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)
diff --git a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/xml/blueprint/BlueprintXmlBeansHandler.java b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/xml/blueprint/BlueprintXmlBeansHandler.java
index c9f2fe64016..f602562d492 100644
--- a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/xml/blueprint/BlueprintXmlBeansHandler.java
+++ b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/xml/blueprint/BlueprintXmlBeansHandler.java
@@ -175,13 +175,32 @@ public class BlueprintXmlBeansHandler {
String key = XmlHelper.getAttribute(child, "name");
String val = XmlHelper.getAttribute(child, "value");
String ref = XmlHelper.getAttribute(child, "ref");
-
- // TODO: List/Map properties
if (key != null && val != null) {
properties.put(key, extractValue(camelContext, val, false));
} else if (key != null && ref != null) {
properties.put(key, extractValue(camelContext, "#bean:" + ref, false));
}
+ for (Node n : getChildNodes(child, "list")) {
+ int j = 0;
+ for (Node v : getChildNodes(n, "value")) {
+ val = v.getTextContent();
+ if (key != null && val != null) {
+ String k = key + "[" + j + "]";
+ properties.put(k, extractValue(camelContext, val, false));
+ }
+ j++;
+ }
+ }
+ for (Node n : getChildNodes(child, "map")) {
+ for (Node v : getChildNodes(n, "entry")) {
+ String k = XmlHelper.getAttribute(v, "key");
+ val = XmlHelper.getAttribute(v, "value");
+ if (key != null && k != null && val != null) {
+ k = key + "[" + k + "]";
+ properties.put(k, extractValue(camelContext, val, false));
+ }
+ }
+ }
}
}
if (!properties.isEmpty()) {
@@ -191,6 +210,18 @@ public class BlueprintXmlBeansHandler {
return rrd;
}
+ private static List<Node> getChildNodes(Node node, String name) {
+ List<Node> answer = new ArrayList<>();
+ NodeList list = node.getChildNodes();
+ for (int j = 0; j < list.getLength(); j++) {
+ Node entry = list.item(j);
+ if (name.equals(entry.getNodeName())) {
+ answer.add(entry);
+ }
+ }
+ return answer;
+ }
+
private void discoverBeans(CamelContext camelContext, String fileName, Document dom) {
Resource resource = camelContext.getCamelContextExtension().getContextPlugin(ResourceLoader.class)
.resolveResource("file:" + fileName);