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.git
The following commit(s) were added to refs/heads/master by this push:
new 036951a Regen
036951a is described below
commit 036951a2eb41183bd3a42edde0c75696ec54268f
Author: Claus Ibsen <[email protected]>
AuthorDate: Tue Aug 25 09:59:35 2020 +0200
Regen
---
.../builder/endpoint/AbstractEndpointBuilder.java | 3 +-
.../camel/support/PropertyBindingSupport.java | 53 +++++++++++++++++++++-
2 files changed, 54 insertions(+), 2 deletions(-)
diff --git
a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/AbstractEndpointBuilder.java
b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/AbstractEndpointBuilder.java
index 008379f..895bf98 100644
---
a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/AbstractEndpointBuilder.java
+++
b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/AbstractEndpointBuilder.java
@@ -73,7 +73,8 @@ public class AbstractEndpointBuilder {
return computeUri(new LinkedHashMap<>(), null, false, true).getUri();
}
- protected NormalizedUri computeUri(Map<String, Object> remaining,
CamelContext camelContext, boolean bindToRegistry, boolean encode) {
+ protected NormalizedUri computeUri(
+ Map<String, Object> remaining, CamelContext camelContext, boolean
bindToRegistry, boolean encode) {
NormalizedUri answer;
// sort parameters so it can be regarded as normalized
diff --git
a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
index 246d339..d0840f4 100644
---
a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
+++
b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
@@ -96,6 +96,7 @@ public final class PropertyBindingSupport {
private CamelContext camelContext;
private Object target;
private Map<String, Object> properties;
+ private Map<String, Map<String, Object>> map;
private boolean removeParameters = true;
private boolean mandatory;
private boolean nesting = true;
@@ -141,6 +142,21 @@ public final class PropertyBindingSupport {
}
/**
+ * The map of map that holds the properties to use.
+ */
+ public Builder map(Map<String, Map<String, Object>> map) {
+ if (this.map == null) {
+ this.map = map;
+ } else {
+ // there may be existing options so add those if missing
+ // we need to mutate existing as we are may be removing bound
properties
+ this.map.forEach(map::putIfAbsent);
+ this.map = map;
+ }
+ return this;
+ }
+
+ /**
* Adds property to use for binding
*/
public Builder withProperty(String key, Object value) {
@@ -260,9 +276,12 @@ public final class PropertyBindingSupport {
org.apache.camel.util.ObjectHelper.notNull(camelContext,
"camelContext");
org.apache.camel.util.ObjectHelper.notNull(target, "target");
- if (properties == null || properties.isEmpty()) {
+ if ((properties == null || properties.isEmpty()) && (map == null
|| map.isEmpty())) {
return false;
}
+ if (properties != null && map != null) {
+ throw new IllegalArgumentException("Only either properties or
map can be used, not both at the same time");
+ }
return doBindProperties(camelContext, target, removeParameters ?
properties : new HashMap<>(properties),
optionPrefix, ignoreCase, true, mandatory,
@@ -282,12 +301,44 @@ public final class PropertyBindingSupport {
Object obj = target != null ? target : this.target;
Map<String, Object> prop = properties != null ? properties :
this.properties;
+ // flattern map as facade for doBindProperties
+ Map<String, Object> facade = flatternMapToProperties(map);
+
return doBindProperties(context, obj, removeParameters ? prop :
new HashMap<>(prop),
optionPrefix, ignoreCase, true, mandatory,
nesting, deepNesting, fluentBuilder, allowPrivateSetter,
reference, placeholder, reflection, configurer);
}
/**
+ * Binds the properties to the target object, and removes the property
that was bound from properties.
+ *
+ * @param camelContext the camel context
+ * @param target the target object
+ * @param map the map of map that holds the properties to use
+ * @return true if one or more properties was bound
+ */
+ public boolean bind(CamelContext camelContext, Object target,
Map<String, Map<String, Object>> map) {
+ CamelContext context = camelContext != null ? camelContext :
this.camelContext;
+ Object obj = target != null ? target : this.target;
+ Map<String, Map<String, Object>> prop = map != null ? map :
this.map;
+ if (!removeParameters) {
+ prop = new HashMap<>(prop);
+ }
+
+ // flattern map as facade for doBindProperties
+ Map<String, Object> facade = flatternMapToProperties(map);
+
+ return doBindProperties(context, obj, facade,
+ optionPrefix, ignoreCase, true, mandatory,
+ nesting, deepNesting, fluentBuilder, allowPrivateSetter,
reference, placeholder, reflection, configurer);
+ }
+
+ private static Map<String, Object> flatternMapToProperties(Map<String,
Map<String, Object>> map) {
+ // TODO:
+
+ }
+
+ /**
* Binds the property to the target object.
*
* @param camelContext the camel context