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 2021/09/20 11:25:31 UTC

[camel] 02/02: CAMEL-16988: camel-dataformat - Do not use reflection when configuring dataformats

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

commit b174e1697b1251ac36f7305239afd3ce783fac7a
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Sep 20 13:24:40 2021 +0200

    CAMEL-16988: camel-dataformat - Do not use reflection when configuring dataformats
---
 .../camel/component/dataformat/DataFormatComponent.java      | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/components/camel-dataformat/src/main/java/org/apache/camel/component/dataformat/DataFormatComponent.java b/components/camel-dataformat/src/main/java/org/apache/camel/component/dataformat/DataFormatComponent.java
index 86a86a1..c5deea0 100644
--- a/components/camel-dataformat/src/main/java/org/apache/camel/component/dataformat/DataFormatComponent.java
+++ b/components/camel-dataformat/src/main/java/org/apache/camel/component/dataformat/DataFormatComponent.java
@@ -19,7 +19,9 @@ package org.apache.camel.component.dataformat;
 import java.util.Map;
 
 import org.apache.camel.Endpoint;
+import org.apache.camel.ExtendedCamelContext;
 import org.apache.camel.spi.DataFormat;
+import org.apache.camel.spi.PropertyConfigurer;
 import org.apache.camel.spi.annotations.Component;
 import org.apache.camel.support.DefaultComponent;
 import org.apache.camel.support.PropertyBindingSupport;
@@ -52,8 +54,16 @@ public class DataFormatComponent extends DefaultComponent {
         if (df == null) {
             throw new IllegalArgumentException("Cannot find data format with name: " + name);
         }
-        PropertyBindingSupport.bindProperties(getCamelContext(), df, parameters);
 
+        // find configurer if any
+        PropertyConfigurer configurer = getCamelContext().adapt(ExtendedCamelContext.class).getConfigurerResolver()
+                .resolvePropertyConfigurer(name + "-dataformat", getCamelContext());
+        // bind properties to data format
+        PropertyBindingSupport.Builder builder = new PropertyBindingSupport.Builder();
+        builder.withConfigurer(configurer);
+        builder.bind(getCamelContext(), df, parameters);
+
+        // create endpoint
         DataFormatEndpoint endpoint = new DataFormatEndpoint(uri, this, df);
         endpoint.setOperation(operation);
         setProperties(endpoint, parameters);