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 2019/09/01 09:27:53 UTC

[camel] branch master updated (bcfec6c -> 01c50db)

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

davsclaus pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from bcfec6c  Regen
     new a1d5438  CAMEL-13913: camel3 - components - Use BeanIntrospection instead of IntrospectionSupport
     new 01c50db  CAMEL-13913: camel3 - components - Use BeanIntrospection instead of IntrospectionSupport

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../component/netty/http/NettyHttpComponent.java   |  9 +++++---
 .../camel/component/netty/NettyComponent.java      |  6 ++++--
 .../camel/component/netty/NettyConfiguration.java  |  6 +++---
 .../slot/PgReplicationSlotComponent.java           |  4 ++--
 .../camel/component/quartz/QuartzComponent.java    | 12 ++++-------
 .../component/rabbitmq/RabbitMQComponent.java      |  6 ++----
 .../camel/component/rabbitmq/RabbitMQEndpoint.java |  9 ++++----
 .../rest/swagger/RestSwaggerDelegateHttpsTest.java |  7 +++++--
 .../apache/camel/component/rest/RestComponent.java | 24 +++++++++-------------
 .../apache/camel/component/rest/RestProducer.java  | 18 ++++++++--------
 .../component/salesforce/SalesforceComponent.java  |  9 +++-----
 .../component/servicenow/ServiceNowComponent.java  |  8 ++++----
 .../apache/camel/component/sql/SqlComponent.java   |  4 ++--
 .../camel/component/twilio/TwilioEndpoint.java     |  8 ++++----
 .../component/undertow/UndertowComponent.java      |  5 ++---
 .../component/wordpress/WordpressComponent.java    |  9 ++++++--
 .../component/wordpress/WordpressEndpoint.java     |  4 ++--
 .../zookeepermaster/ZookeeperGroupSupport.java     |  2 +-
 .../group/internal/ManagedGroupFactoryBuilder.java | 15 ++++++++------
 19 files changed, 84 insertions(+), 81 deletions(-)


[camel] 02/02: CAMEL-13913: camel3 - components - Use BeanIntrospection instead of IntrospectionSupport

Posted by da...@apache.org.
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

commit 01c50dbd7a7a64ddcd3485a6bbebb5bba1a10394
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Sep 1 11:27:35 2019 +0200

    CAMEL-13913: camel3 - components - Use BeanIntrospection instead of IntrospectionSupport
---
 .../rest/swagger/RestSwaggerDelegateHttpsTest.java |  7 +++++--
 .../apache/camel/component/rest/RestComponent.java | 24 +++++++++-------------
 .../apache/camel/component/rest/RestProducer.java  | 18 ++++++++--------
 .../component/salesforce/SalesforceComponent.java  |  9 +++-----
 .../component/servicenow/ServiceNowComponent.java  |  8 ++++----
 .../apache/camel/component/sql/SqlComponent.java   |  4 ++--
 .../camel/component/twilio/TwilioEndpoint.java     |  8 ++++----
 .../component/undertow/UndertowComponent.java      |  5 ++---
 .../component/wordpress/WordpressComponent.java    |  9 ++++++--
 .../component/wordpress/WordpressEndpoint.java     |  4 ++--
 .../zookeepermaster/ZookeeperGroupSupport.java     |  2 +-
 .../group/internal/ManagedGroupFactoryBuilder.java | 15 ++++++++------
 12 files changed, 59 insertions(+), 54 deletions(-)

diff --git a/components/camel-rest-swagger/src/test/java/org/apache/camel/component/rest/swagger/RestSwaggerDelegateHttpsTest.java b/components/camel-rest-swagger/src/test/java/org/apache/camel/component/rest/swagger/RestSwaggerDelegateHttpsTest.java
index 899825c..44da41b 100644
--- a/components/camel-rest-swagger/src/test/java/org/apache/camel/component/rest/swagger/RestSwaggerDelegateHttpsTest.java
+++ b/components/camel-rest-swagger/src/test/java/org/apache/camel/component/rest/swagger/RestSwaggerDelegateHttpsTest.java
@@ -18,8 +18,9 @@ package org.apache.camel.component.rest.swagger;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Component;
+import org.apache.camel.ExtendedCamelContext;
 import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.support.IntrospectionSupport;
+import org.apache.camel.spi.BeanIntrospection;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 
@@ -32,7 +33,9 @@ public class RestSwaggerDelegateHttpsTest extends HttpsTest {
 
         final Component delegate = ((DefaultCamelContext) camelContext).getComponentResolver()
             .resolveComponent(componentName, camelContext);
-        IntrospectionSupport.setProperty(delegate, "sslContextParameters", createHttpsParameters(camelContext));
+
+        BeanIntrospection beanIntrospection = camelContext.adapt(ExtendedCamelContext.class).getBeanIntrospection();
+        beanIntrospection.setProperty(camelContext, delegate, "sslContextParameters", createHttpsParameters(camelContext));
         camelContext.addComponent(componentName, delegate);
 
         return camelContext;
diff --git a/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestComponent.java b/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestComponent.java
index 654bb01..1e824d6 100644
--- a/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestComponent.java
+++ b/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestComponent.java
@@ -17,7 +17,6 @@
 package org.apache.camel.component.rest;
 
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.function.Consumer;
@@ -25,12 +24,13 @@ import java.util.function.Supplier;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
+import org.apache.camel.ExtendedCamelContext;
 import org.apache.camel.component.extension.ComponentVerifierExtension;
+import org.apache.camel.spi.BeanIntrospection;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.RestConfiguration;
 import org.apache.camel.support.CamelContextHelper;
 import org.apache.camel.support.DefaultComponent;
-import org.apache.camel.support.IntrospectionSupport;
 import org.apache.camel.support.PropertyBindingSupport;
 import org.apache.camel.util.FileUtil;
 import org.apache.camel.util.StringHelper;
@@ -72,9 +72,9 @@ public class RestComponent extends DefaultComponent {
         answer.setApiDoc(apiDoc);
 
         RestConfiguration config = new RestConfiguration();
-        mergeConfigurations(config, findGlobalRestConfiguration());
-        mergeConfigurations(config, getCamelContext().getRestConfiguration(cname, false));
-        mergeConfigurations(config, getCamelContext().getRestConfiguration(pname, false));
+        mergeConfigurations(getCamelContext(), config, findGlobalRestConfiguration());
+        mergeConfigurations(getCamelContext(), config, getCamelContext().getRestConfiguration(cname, false));
+        mergeConfigurations(getCamelContext(), config, getCamelContext().getRestConfiguration(pname, false));
 
         // if no explicit host was given, then fallback and use default configured host
         String h = getAndRemoveOrResolveReferenceParameter(parameters, "host", String.class, host);
@@ -232,21 +232,17 @@ public class RestComponent extends DefaultComponent {
         return conf;
     }
 
-    private RestConfiguration mergeConfigurations(RestConfiguration conf, RestConfiguration from) throws Exception {
+    private RestConfiguration mergeConfigurations(CamelContext camelContext, RestConfiguration conf, RestConfiguration from) throws Exception {
         if (conf == from) {
             return conf;
         }
         if (from != null) {
-            Map<String, Object> map = IntrospectionSupport.getNonNullProperties(from);
+            BeanIntrospection beanIntrospection = camelContext.adapt(ExtendedCamelContext.class).getBeanIntrospection();
+            Map<String, Object> map = new HashMap<>();
+            beanIntrospection.getProperties(from, map, null, false);
 
             // Remove properties as they need to be manually managed
-            Iterator<Map.Entry<String, Object>> it = map.entrySet().iterator();
-            while (it.hasNext()) {
-                Map.Entry<String, Object> entry = it.next();
-                if (entry.getValue() instanceof Map) {
-                    it.remove();
-                }
-            }
+            map.entrySet().removeIf(entry -> entry.getValue() instanceof Map);
 
             // Copy common options, will override those in conf
             PropertyBindingSupport.bindProperties(getCamelContext(), conf, map);
diff --git a/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestProducer.java b/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestProducer.java
index 2fe5950..ad4f989 100644
--- a/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestProducer.java
+++ b/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestProducer.java
@@ -31,13 +31,14 @@ import org.apache.camel.AsyncProcessor;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
+import org.apache.camel.ExtendedCamelContext;
 import org.apache.camel.Message;
 import org.apache.camel.Producer;
+import org.apache.camel.spi.BeanIntrospection;
 import org.apache.camel.spi.DataFormat;
 import org.apache.camel.spi.RestConfiguration;
 import org.apache.camel.support.AsyncProcessorConverterHelper;
 import org.apache.camel.support.DefaultAsyncProducer;
-import org.apache.camel.support.IntrospectionSupport;
 import org.apache.camel.support.PropertyBindingSupport;
 import org.apache.camel.support.service.ServiceHelper;
 import org.apache.camel.util.CollectionStringBuffer;
@@ -300,6 +301,7 @@ public class RestProducer extends DefaultAsyncProducer {
             throw new IllegalArgumentException("JSon DataFormat " + name + " not found.");
         }
 
+        BeanIntrospection beanIntrospection = camelContext.adapt(ExtendedCamelContext.class).getBeanIntrospection();
         if (json != null) {
             Class<?> clazz = null;
             if (type != null) {
@@ -307,8 +309,8 @@ public class RestProducer extends DefaultAsyncProducer {
                 clazz = camelContext.getClassResolver().resolveMandatoryClass(typeName);
             }
             if (clazz != null) {
-                IntrospectionSupport.setProperty(camelContext.getTypeConverter(), json, "unmarshalType", clazz);
-                IntrospectionSupport.setProperty(camelContext.getTypeConverter(), json, "useList", type.endsWith("[]"));
+                beanIntrospection.setProperty(camelContext, json, "unmarshalType", clazz);
+                beanIntrospection.setProperty(camelContext, json, "useList", type.endsWith("[]"));
             }
             setAdditionalConfiguration(configuration, camelContext, json, "json.in.");
 
@@ -318,8 +320,8 @@ public class RestProducer extends DefaultAsyncProducer {
                 outClazz = camelContext.getClassResolver().resolveMandatoryClass(typeName);
             }
             if (outClazz != null) {
-                IntrospectionSupport.setProperty(camelContext.getTypeConverter(), outJson, "unmarshalType", outClazz);
-                IntrospectionSupport.setProperty(camelContext.getTypeConverter(), outJson, "useList", outType.endsWith("[]"));
+                beanIntrospection.setProperty(camelContext, outJson, "unmarshalType", outClazz);
+                beanIntrospection.setProperty(camelContext, outJson, "useList", outType.endsWith("[]"));
             }
             setAdditionalConfiguration(configuration, camelContext, outJson, "json.out.");
         }
@@ -352,7 +354,7 @@ public class RestProducer extends DefaultAsyncProducer {
             }
             if (clazz != null) {
                 JAXBContext jc = JAXBContext.newInstance(clazz);
-                IntrospectionSupport.setProperty(camelContext.getTypeConverter(), jaxb, "context", jc);
+                beanIntrospection.setProperty(camelContext, jaxb, "context", jc);
             }
             setAdditionalConfiguration(configuration, camelContext, jaxb, "xml.in.");
 
@@ -363,11 +365,11 @@ public class RestProducer extends DefaultAsyncProducer {
             }
             if (outClazz != null) {
                 JAXBContext jc = JAXBContext.newInstance(outClazz);
-                IntrospectionSupport.setProperty(camelContext.getTypeConverter(), outJaxb, "context", jc);
+                beanIntrospection.setProperty(camelContext, outJaxb, "context", jc);
             } else if (clazz != null) {
                 // fallback and use the context from the input
                 JAXBContext jc = JAXBContext.newInstance(clazz);
-                IntrospectionSupport.setProperty(camelContext.getTypeConverter(), outJaxb, "context", jc);
+                beanIntrospection.setProperty(camelContext, outJaxb, "context", jc);
             }
             setAdditionalConfiguration(configuration, camelContext, outJaxb, "xml.out.");
         }
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java
index bde2318..bd5e214 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java
@@ -680,18 +680,15 @@ public class SalesforceComponent extends DefaultComponent implements SSLContextP
     static RestClient createRestClient(final CamelContext camelContext, final Map<String, Object> properties) throws Exception {
 
         final SalesforceEndpointConfig config = new SalesforceEndpointConfig();
-        // let's work with a copy for IntrospectionSupport so original
-        // properties are intact
+        // let's work with a copy so original properties are intact
         PropertyBindingSupport.bindProperties(camelContext, config, new HashMap<>(properties));
 
         final SalesforceLoginConfig loginConfig = new SalesforceLoginConfig();
-        // let's work with a copy for IntrospectionSupport so original
-        // properties are intact
+        // let's work with a copy so original properties are intact
         PropertyBindingSupport.bindProperties(camelContext, loginConfig, new HashMap<>(properties));
 
         final SSLContextParameters sslContextParameters = Optional.ofNullable(camelContext.getSSLContextParameters()).orElseGet(() -> new SSLContextParameters());
-        // let's work with a copy for IntrospectionSupport so original
-        // properties are intact
+        // let's work with a copy so original properties are intact
         PropertyBindingSupport.bindProperties(camelContext, sslContextParameters, new HashMap<>(properties));
 
         final SslContextFactory sslContextFactory = new SslContextFactory();
diff --git a/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/ServiceNowComponent.java b/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/ServiceNowComponent.java
index ce85d7d..20a1124 100644
--- a/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/ServiceNowComponent.java
+++ b/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/ServiceNowComponent.java
@@ -26,8 +26,8 @@ import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.annotations.Component;
 import org.apache.camel.support.DefaultComponent;
 import org.apache.camel.support.EndpointHelper;
-import org.apache.camel.support.IntrospectionSupport;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.PropertiesHelper;
 
 /**
  * Represents the component that manages {@link ServiceNowEndpoint}.
@@ -230,21 +230,21 @@ public class ServiceNowComponent extends DefaultComponent implements SSLContextP
         final CamelContext context = getCamelContext();
         final ServiceNowConfiguration configuration = this.configuration.copy();
 
-        Map<String, Object> models = IntrospectionSupport.extractProperties(parameters, "model.");
+        Map<String, Object> models = PropertiesHelper.extractProperties(parameters, "model.");
         for (Map.Entry<String, Object> entry : models.entrySet()) {
             configuration.addModel(
                 entry.getKey(),
                 EndpointHelper.resolveParameter(context, (String)entry.getValue(), Class.class));
         }
 
-        Map<String, Object> requestModels = IntrospectionSupport.extractProperties(parameters, "requestModel.");
+        Map<String, Object> requestModels = PropertiesHelper.extractProperties(parameters, "requestModel.");
         for (Map.Entry<String, Object> entry : requestModels.entrySet()) {
             configuration.addRequestModel(
                 entry.getKey(),
                 EndpointHelper.resolveParameter(context, (String)entry.getValue(), Class.class));
         }
 
-        Map<String, Object> responseModels = IntrospectionSupport.extractProperties(parameters, "responseModel.");
+        Map<String, Object> responseModels = PropertiesHelper.extractProperties(parameters, "responseModel.");
         for (Map.Entry<String, Object> entry : responseModels.entrySet()) {
             configuration.addResponseModel(
                 entry.getKey(),
diff --git a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlComponent.java b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlComponent.java
index 24f3d42..0b7133a 100644
--- a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlComponent.java
+++ b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlComponent.java
@@ -26,8 +26,8 @@ import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.annotations.Component;
 import org.apache.camel.support.CamelContextHelper;
 import org.apache.camel.support.DefaultComponent;
-import org.apache.camel.support.IntrospectionSupport;
 import org.apache.camel.support.PropertyBindingSupport;
+import org.apache.camel.util.PropertiesHelper;
 import org.springframework.jdbc.core.JdbcTemplate;
 
 /**
@@ -89,7 +89,7 @@ public class SqlComponent extends DefaultComponent {
         String parameterPlaceholderSubstitute = getAndRemoveParameter(parameters, "placeholder", String.class, "#");
 
         JdbcTemplate jdbcTemplate = new JdbcTemplate(target);
-        Map<String, Object> templateOptions = IntrospectionSupport.extractProperties(parameters, "template.");
+        Map<String, Object> templateOptions = PropertiesHelper.extractProperties(parameters, "template.");
         PropertyBindingSupport.bindProperties(getCamelContext(), jdbcTemplate, templateOptions);
 
         String query = remaining;
diff --git a/components/camel-twilio/src/main/java/org/apache/camel/component/twilio/TwilioEndpoint.java b/components/camel-twilio/src/main/java/org/apache/camel/component/twilio/TwilioEndpoint.java
index 563c146..82dc354 100644
--- a/components/camel-twilio/src/main/java/org/apache/camel/component/twilio/TwilioEndpoint.java
+++ b/components/camel-twilio/src/main/java/org/apache/camel/component/twilio/TwilioEndpoint.java
@@ -23,17 +23,17 @@ import java.util.Map;
 
 import com.twilio.http.TwilioRestClient;
 import org.apache.camel.Consumer;
+import org.apache.camel.ExtendedCamelContext;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.TypeConverter;
 import org.apache.camel.component.twilio.internal.TwilioApiCollection;
 import org.apache.camel.component.twilio.internal.TwilioApiName;
 import org.apache.camel.component.twilio.internal.TwilioConstants;
 import org.apache.camel.component.twilio.internal.TwilioPropertiesHelper;
+import org.apache.camel.spi.BeanIntrospection;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
-import org.apache.camel.support.IntrospectionSupport;
 import org.apache.camel.support.component.AbstractApiEndpoint;
 import org.apache.camel.support.component.ApiMethod;
 import org.apache.camel.support.component.ApiMethodPropertiesHelper;
@@ -104,9 +104,9 @@ public class TwilioEndpoint extends AbstractApiEndpoint<TwilioApiName, TwilioCon
         }
         String methodName = EXECUTOR_METHOD_MAP.get(method.getName());
         try {
-            TypeConverter typeConverter = getCamelContext().getTypeConverter();
+            BeanIntrospection beanIntrospection = getCamelContext().adapt(ExtendedCamelContext.class).getBeanIntrospection();
             for (Map.Entry<String, Object> p : properties.entrySet()) {
-                IntrospectionSupport.setProperty(typeConverter, executor, p.getKey(), p.getValue());
+                beanIntrospection.setProperty(getCamelContext(), executor, p.getKey(), p.getValue());
             }
             return doExecute(executor, methodName, properties);
         } catch (Exception e) {
diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
index 57f9ec4..47b613c 100644
--- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
+++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
@@ -24,7 +24,6 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
-
 import javax.net.ssl.SSLContext;
 
 import io.undertow.server.HttpHandler;
@@ -42,13 +41,13 @@ import org.apache.camel.spi.RestConsumerFactory;
 import org.apache.camel.spi.RestProducerFactory;
 import org.apache.camel.spi.annotations.Component;
 import org.apache.camel.support.DefaultComponent;
-import org.apache.camel.support.IntrospectionSupport;
 import org.apache.camel.support.RestProducerFactoryHelper;
 import org.apache.camel.support.jsse.SSLContextParameters;
 import org.apache.camel.support.service.ServiceHelper;
 import org.apache.camel.util.FileUtil;
 import org.apache.camel.util.HostUtils;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.PropertiesHelper;
 import org.apache.camel.util.URISupport;
 import org.apache.camel.util.UnsafeUriCharactersEncoder;
 
@@ -87,7 +86,7 @@ public class UndertowComponent extends DefaultComponent implements RestConsumerF
         URI endpointUri = URISupport.createRemainingURI(uriHttpUriAddress, parameters);
 
         // any additional channel options
-        Map<String, Object> options = IntrospectionSupport.extractProperties(parameters, "option.");
+        Map<String, Object> options = PropertiesHelper.extractProperties(parameters, "option.");
 
         // determine sslContextParameters
         SSLContextParameters sslParams = this.sslContextParameters;
diff --git a/components/camel-wordpress/src/main/java/org/apache/camel/component/wordpress/WordpressComponent.java b/components/camel-wordpress/src/main/java/org/apache/camel/component/wordpress/WordpressComponent.java
index aee3098..87c5b25 100644
--- a/components/camel-wordpress/src/main/java/org/apache/camel/component/wordpress/WordpressComponent.java
+++ b/components/camel-wordpress/src/main/java/org/apache/camel/component/wordpress/WordpressComponent.java
@@ -21,10 +21,11 @@ import java.util.Map;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
+import org.apache.camel.ExtendedCamelContext;
+import org.apache.camel.spi.BeanIntrospection;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.annotations.Component;
 import org.apache.camel.support.DefaultComponent;
-import org.apache.camel.support.IntrospectionSupport;
 import org.apache.camel.support.PropertyBindingSupport;
 
 /**
@@ -82,7 +83,11 @@ public class WordpressComponent extends DefaultComponent {
 
     private WordpressComponentConfiguration copyComponentProperties() throws Exception {
         Map<String, Object> componentProperties = new HashMap<>();
-        IntrospectionSupport.getProperties(configuration, componentProperties, null, false);
+
+        if (configuration != null) {
+            BeanIntrospection beanIntrospection = getCamelContext().adapt(ExtendedCamelContext.class).getBeanIntrospection();
+            beanIntrospection.getProperties(configuration, componentProperties, null, false);
+        }
 
         // create endpoint configuration with component properties
         WordpressComponentConfiguration config = new WordpressComponentConfiguration();
diff --git a/components/camel-wordpress/src/main/java/org/apache/camel/component/wordpress/WordpressEndpoint.java b/components/camel-wordpress/src/main/java/org/apache/camel/component/wordpress/WordpressEndpoint.java
index 3f3bd3e..a622686 100644
--- a/components/camel-wordpress/src/main/java/org/apache/camel/component/wordpress/WordpressEndpoint.java
+++ b/components/camel-wordpress/src/main/java/org/apache/camel/component/wordpress/WordpressEndpoint.java
@@ -37,9 +37,9 @@ 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.IntrospectionSupport;
 import org.apache.camel.support.PropertyBindingSupport;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.PropertiesHelper;
 
 /**
  * Integrates Camel with Wordpress.
@@ -123,7 +123,7 @@ public class WordpressEndpoint extends DefaultEndpoint {
 
             if (configuration.getSearchCriteria() == null) {
                 final SearchCriteria searchCriteria = WordpressOperationType.valueOf(operation).getCriteriaType().newInstance();
-                Map<String, Object> criteriaOptions = IntrospectionSupport.extractProperties(options, "criteria.");
+                Map<String, Object> criteriaOptions = PropertiesHelper.extractProperties(options, "criteria.");
                 // any property that has a "," should be a List
                 criteriaOptions = criteriaOptions.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> {
                     if (e.toString().contains(",")) {
diff --git a/components/camel-zookeeper-master/src/main/java/org/apache/camel/component/zookeepermaster/ZookeeperGroupSupport.java b/components/camel-zookeeper-master/src/main/java/org/apache/camel/component/zookeepermaster/ZookeeperGroupSupport.java
index a5a8c17..3b6ec4a 100644
--- a/components/camel-zookeeper-master/src/main/java/org/apache/camel/component/zookeepermaster/ZookeeperGroupSupport.java
+++ b/components/camel-zookeeper-master/src/main/java/org/apache/camel/component/zookeepermaster/ZookeeperGroupSupport.java
@@ -139,7 +139,7 @@ public class ZookeeperGroupSupport extends ServiceSupport implements CamelContex
         }
 
         // will auto create curator if needed
-        managedGroupFactory = ManagedGroupFactoryBuilder.create(curator, getClass().getClassLoader(), getCamelContext().getClassResolver(), this);
+        managedGroupFactory = ManagedGroupFactoryBuilder.create(curator, getClass().getClassLoader(), getCamelContext(), this);
     }
 
     @Override
diff --git a/components/camel-zookeeper-master/src/main/java/org/apache/camel/component/zookeepermaster/group/internal/ManagedGroupFactoryBuilder.java b/components/camel-zookeeper-master/src/main/java/org/apache/camel/component/zookeepermaster/group/internal/ManagedGroupFactoryBuilder.java
index aa899f3..0b62dd9 100644
--- a/components/camel-zookeeper-master/src/main/java/org/apache/camel/component/zookeepermaster/group/internal/ManagedGroupFactoryBuilder.java
+++ b/components/camel-zookeeper-master/src/main/java/org/apache/camel/component/zookeepermaster/group/internal/ManagedGroupFactoryBuilder.java
@@ -18,8 +18,10 @@ package org.apache.camel.component.zookeepermaster.group.internal;
 
 import java.util.concurrent.Callable;
 
-import org.apache.camel.spi.ClassResolver;
-import org.apache.camel.support.IntrospectionSupport;
+import org.apache.camel.CamelContext;
+import org.apache.camel.ExtendedCamelContext;
+import org.apache.camel.spi.BeanIntrospection;
+import org.apache.camel.support.ObjectHelper;
 import org.apache.curator.framework.CuratorFramework;
 
 public final class ManagedGroupFactoryBuilder {
@@ -29,16 +31,17 @@ public final class ManagedGroupFactoryBuilder {
 
     public static ManagedGroupFactory create(CuratorFramework curator,
                                              ClassLoader loader,
-                                             ClassResolver resolver,
+                                             CamelContext camelContext,
                                              Callable<CuratorFramework> factory) throws Exception {
         if (curator != null) {
             return new StaticManagedGroupFactory(curator, false);
         }
         try {
-            Class<?> clazz = resolver.resolveClass("org.apache.camel.component.zookeepermaster.group.internal.osgi.OsgiManagedGroupFactory");
+            Class<?> clazz = camelContext.getClassResolver().resolveClass("org.apache.camel.component.zookeepermaster.group.internal.osgi.OsgiManagedGroupFactory");
             if (clazz != null) {
-                Object instance = clazz.newInstance();
-                IntrospectionSupport.setProperty(instance, "classLoader", loader);
+                Object instance = ObjectHelper.newInstance(clazz);
+                BeanIntrospection beanIntrospection = camelContext.adapt(ExtendedCamelContext.class).getBeanIntrospection();
+                beanIntrospection.setProperty(camelContext, instance, "classLoader", loader);
                 return (ManagedGroupFactory) instance;
             }
         } catch (Throwable e) {


[camel] 01/02: CAMEL-13913: camel3 - components - Use BeanIntrospection instead of IntrospectionSupport

Posted by da...@apache.org.
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

commit a1d5438c70c9baa11b31e68d9bfe0e3a6461abf8
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Sep 1 10:37:52 2019 +0200

    CAMEL-13913: camel3 - components - Use BeanIntrospection instead of IntrospectionSupport
---
 .../camel/component/netty/http/NettyHttpComponent.java       |  9 ++++++---
 .../org/apache/camel/component/netty/NettyComponent.java     |  6 ++++--
 .../org/apache/camel/component/netty/NettyConfiguration.java |  6 +++---
 .../pg/replication/slot/PgReplicationSlotComponent.java      |  4 ++--
 .../org/apache/camel/component/quartz/QuartzComponent.java   | 12 ++++--------
 .../apache/camel/component/rabbitmq/RabbitMQComponent.java   |  6 ++----
 .../apache/camel/component/rabbitmq/RabbitMQEndpoint.java    |  9 ++++-----
 7 files changed, 25 insertions(+), 27 deletions(-)

diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
index c65d8c5..ca911bd 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
@@ -24,6 +24,7 @@ import java.util.Map;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Consumer;
 import org.apache.camel.Endpoint;
+import org.apache.camel.ExtendedCamelContext;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.SSLContextParametersAware;
@@ -31,6 +32,7 @@ import org.apache.camel.component.netty.NettyComponent;
 import org.apache.camel.component.netty.NettyConfiguration;
 import org.apache.camel.component.netty.NettyServerBootstrapConfiguration;
 import org.apache.camel.component.netty.http.handlers.HttpServerMultiplexChannelHandler;
+import org.apache.camel.spi.BeanIntrospection;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.spi.HeaderFilterStrategyAware;
 import org.apache.camel.spi.Metadata;
@@ -39,13 +41,13 @@ import org.apache.camel.spi.RestConfiguration;
 import org.apache.camel.spi.RestConsumerFactory;
 import org.apache.camel.spi.RestProducerFactory;
 import org.apache.camel.spi.annotations.Component;
-import org.apache.camel.support.IntrospectionSupport;
 import org.apache.camel.support.PropertyBindingSupport;
 import org.apache.camel.support.RestProducerFactoryHelper;
 import org.apache.camel.support.service.ServiceHelper;
 import org.apache.camel.util.FileUtil;
 import org.apache.camel.util.HostUtils;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.PropertiesHelper;
 import org.apache.camel.util.URISupport;
 import org.apache.camel.util.UnsafeUriCharactersEncoder;
 
@@ -91,14 +93,15 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt
         NettyServerBootstrapConfiguration bootstrapConfiguration = resolveAndRemoveReferenceParameter(parameters, "bootstrapConfiguration", NettyServerBootstrapConfiguration.class);
         if (bootstrapConfiguration != null) {
             Map<String, Object> options = new HashMap<>();
-            if (IntrospectionSupport.getProperties(bootstrapConfiguration, options, null, false)) {
+            BeanIntrospection beanIntrospection = getCamelContext().adapt(ExtendedCamelContext.class).getBeanIntrospection();
+            if (beanIntrospection.getProperties(bootstrapConfiguration, options, null, false)) {
                 PropertyBindingSupport.bindProperties(getCamelContext(), config, options);
             }
         }
 
         // any custom security configuration
         NettyHttpSecurityConfiguration securityConfiguration = resolveAndRemoveReferenceParameter(parameters, "securityConfiguration", NettyHttpSecurityConfiguration.class);
-        Map<String, Object> securityOptions = IntrospectionSupport.extractProperties(parameters, "securityConfiguration.");
+        Map<String, Object> securityOptions = PropertiesHelper.extractProperties(parameters, "securityConfiguration.");
 
         NettyHttpBinding bindingFromUri = resolveAndRemoveReferenceParameter(parameters, "nettyHttpBinding", NettyHttpBinding.class);
 
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java
index 76c42ca..ebaec0b 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java
@@ -25,11 +25,12 @@ import io.netty.util.concurrent.DefaultEventExecutorGroup;
 import io.netty.util.concurrent.EventExecutorGroup;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
+import org.apache.camel.ExtendedCamelContext;
 import org.apache.camel.SSLContextParametersAware;
+import org.apache.camel.spi.BeanIntrospection;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.annotations.Component;
 import org.apache.camel.support.DefaultComponent;
-import org.apache.camel.support.IntrospectionSupport;
 import org.apache.camel.support.PropertyBindingSupport;
 import org.apache.camel.support.jsse.SSLContextParameters;
 import org.apache.camel.util.concurrent.CamelThreadFactory;
@@ -84,7 +85,8 @@ public class NettyComponent extends DefaultComponent implements SSLContextParame
         NettyServerBootstrapConfiguration bootstrapConfiguration = resolveAndRemoveReferenceParameter(parameters, "bootstrapConfiguration", NettyServerBootstrapConfiguration.class);
         if (bootstrapConfiguration != null) {
             Map<String, Object> options = new HashMap<>();
-            if (IntrospectionSupport.getProperties(bootstrapConfiguration, options, null, false)) {
+            BeanIntrospection beanIntrospection = getCamelContext().adapt(ExtendedCamelContext.class).getBeanIntrospection();
+            if (beanIntrospection.getProperties(bootstrapConfiguration, options, null, false)) {
                 PropertyBindingSupport.bindProperties(getCamelContext(), config, options);
             }
         }
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
index 9c5a69e..18f88d2 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
@@ -36,9 +36,9 @@ import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
 import org.apache.camel.support.CamelContextHelper;
 import org.apache.camel.support.EndpointHelper;
-import org.apache.camel.support.IntrospectionSupport;
 import org.apache.camel.support.PropertyBindingSupport;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.PropertiesHelper;
 import org.apache.camel.util.StringHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -198,8 +198,8 @@ public class NettyConfiguration extends NettyServerBootstrapConfiguration implem
         PropertyBindingSupport.bindProperties(component.getCamelContext(), this, parameters);
 
         // additional netty options, we don't want to store an empty map, so set it as null if empty
-        options = IntrospectionSupport.extractProperties(parameters, "option.");
-        if (options != null && options.isEmpty()) {
+        options = PropertiesHelper.extractProperties(parameters, "option.");
+        if (options.isEmpty()) {
             options = null;
         }
 
diff --git a/components/camel-pg-replication-slot/src/main/java/org/apache/camel/component/pg/replication/slot/PgReplicationSlotComponent.java b/components/camel-pg-replication-slot/src/main/java/org/apache/camel/component/pg/replication/slot/PgReplicationSlotComponent.java
index 3059b4f..2bf712c 100644
--- a/components/camel-pg-replication-slot/src/main/java/org/apache/camel/component/pg/replication/slot/PgReplicationSlotComponent.java
+++ b/components/camel-pg-replication-slot/src/main/java/org/apache/camel/component/pg/replication/slot/PgReplicationSlotComponent.java
@@ -21,7 +21,7 @@ import java.util.Map;
 import org.apache.camel.Endpoint;
 import org.apache.camel.spi.annotations.Component;
 import org.apache.camel.support.DefaultComponent;
-import org.apache.camel.support.IntrospectionSupport;
+import org.apache.camel.util.PropertiesHelper;
 
 /**
  * Represents the component that manages {@link PgReplicationSlotEndpoint}.
@@ -34,7 +34,7 @@ public class PgReplicationSlotComponent extends DefaultComponent {
         PgReplicationSlotEndpoint endpoint = new PgReplicationSlotEndpoint(uri, this);
         setProperties(endpoint, parameters);
 
-        Map<String, Object> slotOptions = IntrospectionSupport.extractProperties(parameters, "slotOptions.");
+        Map<String, Object> slotOptions = PropertiesHelper.extractProperties(parameters, "slotOptions.");
         endpoint.setSlotOptions(slotOptions);
 
         return endpoint;
diff --git a/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java b/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java
index 72d53aa..7969931 100644
--- a/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java
+++ b/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java
@@ -29,10 +29,10 @@ import org.apache.camel.ExtendedStartupListener;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.annotations.Component;
 import org.apache.camel.support.DefaultComponent;
-import org.apache.camel.support.IntrospectionSupport;
 import org.apache.camel.support.ResourceHelper;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.PropertiesHelper;
 import org.apache.camel.util.StringHelper;
 import org.quartz.Scheduler;
 import org.quartz.SchedulerContext;
@@ -42,12 +42,8 @@ import org.quartz.TriggerKey;
 import org.quartz.impl.StdSchedulerFactory;
 
 /**
- * A factory for QuartzEndpoint. This component will hold a Quartz Scheduler that will provide scheduled timer based
+ * This component will hold a Quartz Scheduler that will provide scheduled timer based
  * endpoint that generate a QuartzMessage to a route. Currently it support Cron and Simple trigger scheduling type.
- *
- * <p>This component uses Quartz 2.x API and provide all the features from "camel-quartz". It has reused some
- * of the code, but mostly has been re-written in attempt to be more easier to maintain, and use Quartz more
- * fully.</p>
  */
 @Component("quartz")
 public class QuartzComponent extends DefaultComponent implements ExtendedStartupListener {
@@ -341,8 +337,8 @@ public class QuartzComponent extends DefaultComponent implements ExtendedStartup
         }
 
         // Extract trigger.XXX and job.XXX properties to be set on endpoint below
-        Map<String, Object> triggerParameters = IntrospectionSupport.extractProperties(parameters, "trigger.");
-        Map<String, Object> jobParameters = IntrospectionSupport.extractProperties(parameters, "job.");
+        Map<String, Object> triggerParameters = PropertiesHelper.extractProperties(parameters, "trigger.");
+        Map<String, Object> jobParameters = PropertiesHelper.extractProperties(parameters, "job.");
 
         // Create quartz endpoint
         QuartzEndpoint result = new QuartzEndpoint(uri, this);
diff --git a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQComponent.java b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQComponent.java
index e0da35a..ebfd4ec 100644
--- a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQComponent.java
+++ b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQComponent.java
@@ -19,16 +19,14 @@ package org.apache.camel.component.rabbitmq;
 import java.net.URI;
 import java.util.HashMap;
 import java.util.Map;
-
 import javax.net.ssl.TrustManager;
 
-import com.rabbitmq.client.Address;
 import com.rabbitmq.client.ConnectionFactory;
 import org.apache.camel.CamelContext;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.annotations.Component;
 import org.apache.camel.support.DefaultComponent;
-import org.apache.camel.support.IntrospectionSupport;
+import org.apache.camel.util.PropertiesHelper;
 
 @Component("rabbitmq")
 public class RabbitMQComponent extends DefaultComponent {
@@ -254,7 +252,7 @@ public class RabbitMQComponent extends DefaultComponent {
             // copy over the component configured args
             localArgs.putAll(getArgs());
         }
-        localArgs.putAll(IntrospectionSupport.extractProperties(params, ARG_PREFIX));
+        localArgs.putAll(PropertiesHelper.extractProperties(params, ARG_PREFIX));
         endpoint.setArgs(localArgs);
 
         // Change null headers processing for message converter
diff --git a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java
index 58db20a..dee053f 100644
--- a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java
+++ b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java
@@ -22,7 +22,6 @@ import java.util.UUID;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeoutException;
-
 import javax.net.ssl.TrustManager;
 
 import com.rabbitmq.client.AMQP;
@@ -41,7 +40,7 @@ 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.IntrospectionSupport;
+import org.apache.camel.util.PropertiesHelper;
 import org.apache.camel.util.URISupport;
 
 import static org.apache.camel.component.rabbitmq.RabbitMQComponent.BINDING_ARG_PREFIX;
@@ -790,15 +789,15 @@ public class RabbitMQEndpoint extends DefaultEndpoint implements AsyncEndpoint {
     }
 
     public Map<String, Object> getExchangeArgs() {
-        return IntrospectionSupport.extractProperties(args, EXCHANGE_ARG_PREFIX);
+        return PropertiesHelper.extractProperties(args, EXCHANGE_ARG_PREFIX);
     }
 
     public Map<String, Object> getQueueArgs() {
-        return IntrospectionSupport.extractProperties(args, QUEUE_ARG_PREFIX);
+        return PropertiesHelper.extractProperties(args, QUEUE_ARG_PREFIX);
     }
 
     public Map<String, Object> getBindingArgs() {
-        return IntrospectionSupport.extractProperties(args, BINDING_ARG_PREFIX);
+        return PropertiesHelper.extractProperties(args, BINDING_ARG_PREFIX);
     }
 
      /**