You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/11/13 07:34:27 UTC

[camel] 02/05: CAMEL-15836 - Camel-AWS2-S3: enable autowire on the s3 client, removed the autodiscoverClient option, useless now

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 66912ba6874a8335b9e30f16a53e37bff5328337
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Nov 13 08:21:41 2020 +0100

    CAMEL-15836 - Camel-AWS2-S3: enable autowire on the s3 client, removed the autodiscoverClient option, useless now
---
 .../camel/component/aws2/s3/AWS2S3Component.java       | 18 ------------------
 .../camel/component/aws2/s3/AWS2S3Configuration.java   | 14 --------------
 .../aws2/s3/S3ComponentConfigurationTest.java          |  4 ++--
 3 files changed, 2 insertions(+), 34 deletions(-)

diff --git a/components/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Component.java b/components/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Component.java
index 9120405..eac0103 100644
--- a/components/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Component.java
+++ b/components/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Component.java
@@ -61,9 +61,6 @@ public class AWS2S3Component extends DefaultComponent {
         configuration.setBucketName(remaining);
         AWS2S3Endpoint endpoint = new AWS2S3Endpoint(uri, this, configuration);
         setProperties(endpoint, parameters);
-        if (endpoint.getConfiguration().isAutoDiscoverClient()) {
-            checkAndSetRegistryClient(configuration, endpoint);
-        }
         if (!configuration.isUseIAMCredentials() && configuration.getAmazonS3Client() == null
                 && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
             throw new IllegalArgumentException(
@@ -83,19 +80,4 @@ public class AWS2S3Component extends DefaultComponent {
     public void setConfiguration(AWS2S3Configuration configuration) {
         this.configuration = configuration;
     }
-
-    private void checkAndSetRegistryClient(AWS2S3Configuration configuration, AWS2S3Endpoint endpoint) {
-        if (ObjectHelper.isEmpty(endpoint.getConfiguration().getAmazonS3Client())) {
-            LOG.debug("Looking for an S3Client instance in the registry");
-            Set<S3Client> clients = getCamelContext().getRegistry().findByType(S3Client.class);
-            if (clients.size() == 1) {
-                LOG.debug("Found exactly one S3Client instance in the registry");
-                configuration.setAmazonS3Client(clients.stream().findFirst().get());
-            } else {
-                LOG.debug("No S3Client instance in the registry");
-            }
-        } else {
-            LOG.debug("S3Client instance is already set at endpoint level: skipping the check in the registry");
-        }
-    }
 }
diff --git a/components/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Configuration.java b/components/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Configuration.java
index 36e6ace..eedddbc 100644
--- a/components/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Configuration.java
+++ b/components/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Configuration.java
@@ -104,8 +104,6 @@ public class AWS2S3Configuration implements Cloneable {
     private String uriEndpointOverride;
     @UriParam(defaultValue = "false")
     private boolean pojoRequest;
-    @UriParam(label = "common", defaultValue = "true")
-    private boolean autoDiscoverClient = true;
 
     public long getPartSize() {
         return partSize;
@@ -549,18 +547,6 @@ public class AWS2S3Configuration 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;
-    }
-
     public AWS2S3Configuration copy() {
         try {
             return (AWS2S3Configuration) super.clone();
diff --git a/components/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/S3ComponentConfigurationTest.java b/components/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/S3ComponentConfigurationTest.java
index cf978ce..1ef6d76 100644
--- a/components/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/S3ComponentConfigurationTest.java
+++ b/components/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/S3ComponentConfigurationTest.java
@@ -44,14 +44,14 @@ public class S3ComponentConfigurationTest extends CamelTestSupport {
         context.getRegistry().bind("amazonS3Client", client);
         AWS2S3Component component = context.getComponent("aws2-s3", AWS2S3Component.class);
         AWS2S3Endpoint endpoint = (AWS2S3Endpoint) component.createEndpoint(
-                "aws2-s3://MyBucket?accessKey=RAW(XXX)&secretKey=RAW(XXX)&region=eu-west-1&autoDiscoverClient=false");
+                "aws2-s3://MyBucket?accessKey=RAW(XXX)&secretKey=RAW(XXX)&region=eu-west-1");
 
         assertEquals("MyBucket", endpoint.getConfiguration().getBucketName());
         assertSame(client, endpoint.getConfiguration().getAmazonS3Client());
     }
 
     @Test
-    public void createEndpointWithCredentialsAndClientExistInRegistryWithAutodiscover() throws Exception {
+    public void createEndpointWithCredentialsAndClientExistInRegistryWithAutowire() throws Exception {
         S3Client client = S3Client.builder().region(Region.EU_WEST_1).build();
         context.getRegistry().bind("amazonS3Client", client);
         AWS2S3Component component = context.getComponent("aws2-s3", AWS2S3Component.class);