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 50ac96827d9 CAMEL-18500: camel-kamelet - Avoid using reflection when 
setting properties.
50ac96827d9 is described below

commit 50ac96827d93b613a8e4b193e61d7f20209d3e07
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Sep 12 17:59:50 2022 +0200

    CAMEL-18500: camel-kamelet - Avoid using reflection when setting properties.
---
 .../apache/camel/component/kamelet/KameletEndpoint.java | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git 
a/components/camel-kamelet/src/main/java/org/apache/camel/component/kamelet/KameletEndpoint.java
 
b/components/camel-kamelet/src/main/java/org/apache/camel/component/kamelet/KameletEndpoint.java
index 7a426ab54e4..af79b4cbc1d 100644
--- 
a/components/camel-kamelet/src/main/java/org/apache/camel/component/kamelet/KameletEndpoint.java
+++ 
b/components/camel-kamelet/src/main/java/org/apache/camel/component/kamelet/KameletEndpoint.java
@@ -25,10 +25,12 @@ import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.PropertyConfigurer;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriPath;
 import org.apache.camel.support.DefaultEndpoint;
+import org.apache.camel.support.PropertyBindingSupport;
 import org.apache.camel.util.ObjectHelper;
 
 @UriEndpoint(firstVersion = "3.8.0", scheme = "kamelet", syntax = 
"kamelet:templateId/routeId", title = "Kamelet",
@@ -165,4 +167,19 @@ public class KameletEndpoint extends DefaultEndpoint {
         return answer;
     }
 
+    @Override
+    public void setProperties(Object bean, Map<String, Object> parameters) {
+        if (parameters == null || parameters.isEmpty()) {
+            return;
+        }
+
+        PropertyConfigurer configurer = null;
+        if (bean instanceof KameletEndpoint) {
+            configurer = getComponent().getEndpointPropertyConfigurer();
+        }
+        
PropertyBindingSupport.build().withConfigurer(configurer).withIgnoreCase(true)
+                .withOptional(isLenientProperties())
+                .withReflection(false) // avoid reflection as additional 
parameters are for the actual kamelet and not this endpoint
+                .bind(getCamelContext(), bean, parameters);
+    }
 }

Reply via email to