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

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

commit f65dc73b73300798905cf6fe24b6a212b983f207
Author: Andrea Cosentino <[email protected]>
AuthorDate: Sat Nov 14 18:31:53 2020 +0100

    CAMEL-15836 - Camel-AWS2-MQ: enable autowire on the MQ client
---
 .../camel/component/aws2/mq/MQ2Component.java       | 21 ---------------------
 .../camel/component/aws2/mq/MQ2Configuration.java   | 15 +--------------
 2 files changed, 1 insertion(+), 35 deletions(-)

diff --git 
a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Component.java
 
b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Component.java
index 2d71eda..f090191 100644
--- 
a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Component.java
+++ 
b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Component.java
@@ -17,17 +17,14 @@
 package org.apache.camel.component.aws2.mq;
 
 import java.util.Map;
-import java.util.Set;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.annotations.Component;
 import org.apache.camel.support.DefaultComponent;
-import org.apache.camel.util.ObjectHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.services.mq.MqClient;
 
 /**
  * For working with Amazon MQ SDK v2.
@@ -55,9 +52,6 @@ public class MQ2Component extends DefaultComponent {
         MQ2Configuration configuration = this.configuration != null ? 
this.configuration.copy() : new MQ2Configuration();
         MQ2Endpoint endpoint = new MQ2Endpoint(uri, this, configuration);
         setProperties(endpoint, parameters);
-        if (endpoint.getConfiguration().isAutoDiscoverClient()) {
-            checkAndSetRegistryClient(configuration, endpoint);
-        }
         if (configuration.getAmazonMqClient() == null
                 && (configuration.getAccessKey() == null || 
configuration.getSecretKey() == null)) {
             throw new IllegalArgumentException("amazonMQClient or accessKey 
and secretKey must be specified");
@@ -76,19 +70,4 @@ public class MQ2Component extends DefaultComponent {
     public void setConfiguration(MQ2Configuration configuration) {
         this.configuration = configuration;
     }
-
-    private void checkAndSetRegistryClient(MQ2Configuration configuration, 
MQ2Endpoint endpoint) {
-        if 
(ObjectHelper.isEmpty(endpoint.getConfiguration().getAmazonMqClient())) {
-            LOG.debug("Looking for an MqClient instance in the registry");
-            Set<MqClient> clients = 
getCamelContext().getRegistry().findByType(MqClient.class);
-            if (clients.size() == 1) {
-                LOG.debug("Found exactly one MqClient instance in the 
registry");
-                
configuration.setAmazonMqClient(clients.stream().findFirst().get());
-            } else {
-                LOG.debug("No MqClient instance in the registry");
-            }
-        } else {
-            LOG.debug("MqClient instance is already set at endpoint level: 
skipping the check in the registry");
-        }
-    }
 }
diff --git 
a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Configuration.java
 
b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Configuration.java
index e025984..0119509 100644
--- 
a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Configuration.java
+++ 
b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Configuration.java
@@ -31,6 +31,7 @@ public class MQ2Configuration implements Cloneable {
     @Metadata(required = true)
     private String label;
     @UriParam
+    @Metadata(autowired = true)    
     private MqClient amazonMqClient;
     @UriParam(label = "security", secret = true)
     private String accessKey;
@@ -51,8 +52,6 @@ public class MQ2Configuration implements Cloneable {
     private boolean pojoRequest;
     @UriParam(defaultValue = "false")
     private boolean trustAllCertificates;
-    @UriParam(label = "common", defaultValue = "true")
-    private boolean autoDiscoverClient = true;
 
     public MqClient getAmazonMqClient() {
         return amazonMqClient;
@@ -165,18 +164,6 @@ public class MQ2Configuration implements Cloneable {
         this.trustAllCertificates = trustAllCertificates;
     }
 
-    public boolean isAutoDiscoverClient() {
-        return autoDiscoverClient;
-    }
-
-    /**
-     * Setting the autoDiscoverClient mechanism, if true, the component will 
look for a client instance in the registry
-     * automatically otherwise it will skip that checking.
-     */
-    public void setAutoDiscoverClient(boolean autoDiscoverClient) {
-        this.autoDiscoverClient = autoDiscoverClient;
-    }
-
     // *************************************************
     //
     // *************************************************

Reply via email to