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 6d8b1630914360a74031d91962db324a47d87364
Author: Andrea Cosentino <[email protected]>
AuthorDate: Wed Nov 18 15:03:17 2020 +0100

    CAMEL-15836 - Camel-AWS2-Athena: enable autowire on the Athena Client
---
 .../camel/component/aws2/athena/Athena2Component.java  | 18 ------------------
 .../component/aws2/athena/Athena2Configuration.java    | 17 +----------------
 2 files changed, 1 insertion(+), 34 deletions(-)

diff --git 
a/components/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Component.java
 
b/components/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Component.java
index feb354d..0aa78d7 100644
--- 
a/components/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Component.java
+++ 
b/components/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Component.java
@@ -55,9 +55,6 @@ public class Athena2Component extends DefaultComponent {
                 = this.configuration != null ? this.configuration.copy() : new 
Athena2Configuration();
         Athena2Endpoint endpoint = new Athena2Endpoint(uri, this, 
configuration);
         setProperties(endpoint, parameters);
-        if (endpoint.getConfiguration().isAutoDiscoverClient()) {
-            checkAndSetRegistryClient(configuration, endpoint);
-        }
         if (configuration.getAmazonAthenaClient() == null && 
(configuration.getAccessKey() == null
                 || configuration.getSecretKey() == null)) {
             throw new IllegalArgumentException("accessKey/secretKey or 
amazonAthenaClient must be specified");
@@ -75,19 +72,4 @@ public class Athena2Component extends DefaultComponent {
     public void setConfiguration(Athena2Configuration configuration) {
         this.configuration = configuration;
     }
-
-    private void checkAndSetRegistryClient(Athena2Configuration configuration, 
Athena2Endpoint endpoint) {
-        if 
(ObjectHelper.isEmpty(endpoint.getConfiguration().getAmazonAthenaClient())) {
-            LOG.debug("Looking for an AthenaClient instance in the registry");
-            Set<AthenaClient> clients = 
getCamelContext().getRegistry().findByType(AthenaClient.class);
-            if (clients.size() == 1) {
-                LOG.debug("Found exactly one AthenaClient instance in the 
registry");
-                
configuration.setAmazonAthenaClient(clients.stream().findFirst().get());
-            } else {
-                LOG.debug("No AthenaClient instance in the registry");
-            }
-        } else {
-            LOG.debug("AthenaClient instance is already set at endpoint level: 
skipping the check in the registry");
-        }
-    }
 }
diff --git 
a/components/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Configuration.java
 
b/components/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Configuration.java
index 19af5ab..9180697 100644
--- 
a/components/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Configuration.java
+++ 
b/components/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Configuration.java
@@ -122,6 +122,7 @@ public class Athena2Configuration implements Cloneable {
     private boolean resetWaitTimeoutOnRetry = true;
 
     @UriParam
+    @Metadata(autowired = true)
     private AthenaClient amazonAthenaClient;
     @UriParam(label = "producer", secret = true)
     private String accessKey;
@@ -135,10 +136,6 @@ public class Athena2Configuration implements Cloneable {
     private Integer proxyPort;
     @UriParam
     private String region;
-    @UriParam(label = "common", defaultValue = "true",
-              description = "Setting the autoDiscoverClient mechanism, if 
true, the component will "
-                            + " look for a client instance in the registry 
automatically otherwise it will skip that checking")
-    private boolean autoDiscoverClient = true;
 
     public String getAccessKey() {
         return accessKey;
@@ -444,18 +441,6 @@ public class Athena2Configuration implements Cloneable {
         this.includeTrace = includeTrace;
     }
 
-    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