[camel] branch master updated: CAMEL-13557: Add property binding support to make it convenient to configure components and whatnot.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[camel] branch master updated: CAMEL-13557: Add property binding support to make it convenient to configure components and whatnot.

davsclaus-2
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 51a17b4  CAMEL-13557: Add property binding support to make it convenient to configure components and whatnot.
51a17b4 is described below

commit 51a17b4f24a4fd65e5c40466fbd67cae0d2f69ce
Author: Claus Ibsen <[hidden email]>
AuthorDate: Fri May 24 14:57:01 2019 +0200

    CAMEL-13557: Add property binding support to make it convenient to configure components and whatnot.
---
 .../org/apache/camel/support/DefaultComponent.java |  2 +-
 .../org/apache/camel/support/DefaultEndpoint.java  |  3 +--
 .../camel/support/PropertyBindingSupport.java      | 27 ++++++++++------------
 3 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/core/camel-support/src/main/java/org/apache/camel/support/DefaultComponent.java b/core/camel-support/src/main/java/org/apache/camel/support/DefaultComponent.java
index ba16cf3..d6f1583 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/DefaultComponent.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/DefaultComponent.java
@@ -318,7 +318,7 @@ public abstract class DefaultComponent extends ServiceSupport implements Compone
         if (basicPropertyBinding) {
             // use basic binding
             PropertyBindingSupport.build()
-                    .withPlaceholder(false).withNesting(false).withNestingDeep(false).withReference(false)
+                    .withPlaceholder(false).withNesting(false).withDeepNesting(false).withReference(false)
                     .bind(camelContext, bean, parameters);
         } else {
             // use advanced binding
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/DefaultEndpoint.java b/core/camel-support/src/main/java/org/apache/camel/support/DefaultEndpoint.java
index d2cd157..aadc56b 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/DefaultEndpoint.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/DefaultEndpoint.java
@@ -31,7 +31,6 @@ import org.apache.camel.PollingConsumer;
 import org.apache.camel.ResolveEndpointFailedException;
 import org.apache.camel.spi.ExceptionHandler;
 import org.apache.camel.spi.HasId;
-import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.support.service.ServiceSupport;
 import org.apache.camel.util.ObjectHelper;
@@ -386,7 +385,7 @@ public abstract class DefaultEndpoint extends ServiceSupport implements Endpoint
         if (basicPropertyBinding) {
             // use basic binding
             PropertyBindingSupport.build()
-                    .withPlaceholder(false).withNesting(false).withNestingDeep(false).withReference(false)
+                    .withPlaceholder(false).withNesting(false).withDeepNesting(false).withReference(false)
                     .bind(camelContext, bean, parameters);
         } else {
             // use advanced binding
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 7a21929..9df91de 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
@@ -24,10 +24,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.Component;
-import org.apache.camel.ExtendedCamelContext;
 import org.apache.camel.PropertyBindingException;
-import org.apache.camel.runtimecatalog.RuntimeCamelCatalog;
 
 import static org.apache.camel.support.IntrospectionSupport.findSetterMethods;
 import static org.apache.camel.support.IntrospectionSupport.getOrElseProperty;
@@ -55,7 +52,7 @@ public final class PropertyBindingSupport {
     public static class Builder {
 
         private boolean nesting = true;
-        private boolean nestingDeep = true;
+        private boolean deepNesting = true;
         private boolean reference = true;
         private boolean placeholder = true;
         private boolean fluentBuilder = true;
@@ -72,8 +69,8 @@ public final class PropertyBindingSupport {
          * Whether deep nesting is in use, where Camel will attempt to walk as deep as possible by creating new objects in the OGNL graph if
          * a property has a setter and the object can be created from a default no-arg constructor.
          */
-        public Builder withNestingDeep(boolean nestingDeep) {
-            this.nestingDeep = nestingDeep;
+        public Builder withDeepNesting(boolean deepNesting) {
+            this.deepNesting = deepNesting;
             return this;
         }
 
@@ -114,7 +111,7 @@ public final class PropertyBindingSupport {
             org.apache.camel.util.ObjectHelper.notNull(target, "target");
             org.apache.camel.util.ObjectHelper.notNull(properties, "properties");
 
-            return bindProperties(camelContext, target, properties, nesting, nestingDeep, fluentBuilder, reference, placeholder);
+            return bindProperties(camelContext, target, properties, nesting, deepNesting, fluentBuilder, reference, placeholder);
         }
 
     }
@@ -215,7 +212,7 @@ public final class PropertyBindingSupport {
                     }
                 }
 
-                // TODO: Support creating new instances to walk down the tree if its null
+                // TODO: Support creating new instances to walk down the tree if its null (deepNesting option)
 
                 // remember this as parent and also autowire nested properties
                 // do not walk down if it point to our-selves (circular reference)
@@ -248,7 +245,7 @@ public final class PropertyBindingSupport {
      * @param target        the target object
      * @param properties    the properties where the bound properties will be removed from
      * @param nesting       whether nesting is in use
-     * @param nestingDeep   whether deep nesting is in use, where Camel will attempt to walk as deep as possible by creating new objects in the OGNL graph if
+     * @param deepNesting   whether deep nesting is in use, where Camel will attempt to walk as deep as possible by creating new objects in the OGNL graph if
      *                      a property has a setter and the object can be created from a default no-arg constructor.
      * @param fluentBuilder whether fluent builder is allowed as a valid getter/setter
      * @param reference     whether reference parameter (syntax starts with #) is in use
@@ -256,7 +253,7 @@ public final class PropertyBindingSupport {
      * @return              true if one or more properties was bound
      */
     public static boolean bindProperties(CamelContext camelContext, Object target, Map<String, Object> properties,
-                                         boolean nesting, boolean nestingDeep, boolean fluentBuilder, boolean reference, boolean placeholder) {
+                                         boolean nesting, boolean deepNesting, boolean fluentBuilder, boolean reference, boolean placeholder) {
         org.apache.camel.util.ObjectHelper.notNull(camelContext, "camelContext");
         org.apache.camel.util.ObjectHelper.notNull(target, "target");
         org.apache.camel.util.ObjectHelper.notNull(properties, "properties");
@@ -264,7 +261,7 @@ public final class PropertyBindingSupport {
 
         for (Iterator<Map.Entry<String, Object>> iter = properties.entrySet().iterator(); iter.hasNext();) {
             Map.Entry<String, Object> entry = iter.next();
-            if (bindProperty(camelContext, target, entry.getKey(), entry.getValue(), nesting, nestingDeep, fluentBuilder, reference, placeholder)) {
+            if (bindProperty(camelContext, target, entry.getKey(), entry.getValue(), nesting, deepNesting, fluentBuilder, reference, placeholder)) {
                 iter.remove();
                 rc = true;
             }
@@ -295,10 +292,10 @@ public final class PropertyBindingSupport {
     }
 
     private static boolean bindProperty(CamelContext camelContext, Object target, String name, Object value,
-                                boolean nesting, boolean nestingDeep, boolean fluentBuilder, boolean reference, boolean placeholder) {
+                                boolean nesting, boolean deepNesting, boolean fluentBuilder, boolean reference, boolean placeholder) {
         try {
             if (target != null && name != null) {
-                return setProperty(camelContext, target, name, value, nesting, nestingDeep, fluentBuilder, reference, placeholder);
+                return setProperty(camelContext, target, name, value, nesting, deepNesting, fluentBuilder, reference, placeholder);
             }
         } catch (Exception e) {
             throw new PropertyBindingException(target, name, e);
@@ -329,7 +326,7 @@ public final class PropertyBindingSupport {
     }
 
     private static boolean setProperty(CamelContext context, Object target, String name, Object value,
-                                       boolean nesting, boolean nestingDeep, boolean fluentBuilder, boolean reference, boolean placeholder) throws Exception {
+                                       boolean nesting, boolean deepNesting, boolean fluentBuilder, boolean reference, boolean placeholder) throws Exception {
         String refName = null;
 
         if (placeholder) {
@@ -352,7 +349,7 @@ public final class PropertyBindingSupport {
                     String part = parts[i];
                     Object prop = getOrElseProperty(newTarget, part, null);
                     if (prop == null) {
-                        if (!nestingDeep) {
+                        if (!deepNesting) {
                             // okay we cannot go further down
                             break;
                         }