This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch CAMEL-15224
in repository https://gitbox.apache.org/repos/asf/camel.git

commit da89e21e24bdfc99f8a776b60af68236c60d4dd0
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Mon Jun 22 14:12:39 2020 +0200

    CAMEL-15224: camel-api-component - Avoid reflection when configured nested 
configuration classes.
---
 .../olingo4/Olingo4ComponentConsumerTest.java      |  6 +++++
 .../component/ApiMethodPropertiesHelper.java       | 29 +++++++++++-----------
 2 files changed, 21 insertions(+), 14 deletions(-)

diff --git 
a/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentConsumerTest.java
 
b/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentConsumerTest.java
index d9432b8..42674b8 100644
--- 
a/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentConsumerTest.java
+++ 
b/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentConsumerTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.olingo4;
 
 import java.util.Iterator;
 
+import org.apache.camel.ExtendedCamelContext;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.olingo.client.api.domain.ClientCollectionValue;
@@ -80,6 +81,11 @@ public class Olingo4ComponentConsumerTest extends 
AbstractOlingo4TestSupport {
                 assertEquals("russellwhyte", nameProp.getValue().toString());
             }
         }
+
+        // should be reflection free
+        // TODO: Fix me
+        // long counter = 
context.adapt(ExtendedCamelContext.class).getBeanIntrospection().getInvokedCounter();
+        // assertEquals(0, counter);
     }
 
     /**
diff --git 
a/core/camel-support/src/main/java/org/apache/camel/support/component/ApiMethodPropertiesHelper.java
 
b/core/camel-support/src/main/java/org/apache/camel/support/component/ApiMethodPropertiesHelper.java
index 229664f..fabd135 100644
--- 
a/core/camel-support/src/main/java/org/apache/camel/support/component/ApiMethodPropertiesHelper.java
+++ 
b/core/camel-support/src/main/java/org/apache/camel/support/component/ApiMethodPropertiesHelper.java
@@ -107,24 +107,25 @@ public abstract class ApiMethodPropertiesHelper<C> {
     public void getEndpointProperties(CamelContext context, Object 
endpointConfiguration, Map<String, Object> properties) {
         Set<String> names;
 
-        // TODO: Make this work
         PropertyConfigurer configurer = 
context.adapt(ExtendedCamelContext.class).getConfigurerResolver().resolvePropertyConfigurer(endpointConfiguration.getClass().getSimpleName(),
 context);
         // use reflection free configurer (if possible)
-//        if (configurer instanceof PropertyConfigurerGetter) {
-//            PropertyConfigurerGetter getter = (PropertyConfigurerGetter) 
configurer;
-//            names = getter.getAllOptions(endpointConfiguration).keySet();
-//            for (String name : names) {
-//                Object value = getter.getOptionValue(endpointConfiguration, 
name, true);
-//                if (value != null) {
-//                     lower case the first letter which is what the 
properties map expects
-//                    String key = Character.toLowerCase(name.charAt(0)) + 
name.substring(1);
-//                    properties.put(key, value);
-//                }
-//            }
-//        } else {
+        // TODO: fix me
+        boolean useConfigurer = false;
+        if (useConfigurer && configurer instanceof PropertyConfigurerGetter) {
+            PropertyConfigurerGetter getter = (PropertyConfigurerGetter) 
configurer;
+            names = getter.getAllOptions(endpointConfiguration).keySet();
+            for (String name : names) {
+                Object value = getter.getOptionValue(endpointConfiguration, 
name, true);
+                if (value != null) {
+                    // lower case the first letter which is what the 
properties map expects
+                    String key = Character.toLowerCase(name.charAt(0)) + 
name.substring(1);
+                    properties.put(key, value);
+                }
+            }
+        } else {
             
context.adapt(ExtendedCamelContext.class).getBeanIntrospection().getProperties(endpointConfiguration,
 properties, null, false);
             names = properties.keySet();
-//        }
+        }
         // remove component config properties so we only have endpoint 
properties
         names.removeAll(componentConfigFields);
         LOG.debug("Found endpoint properties {}", names);

Reply via email to