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/16 07:05:44 UTC

[camel] 01/06: CAMEL-15836 - Camel-AWS2-ECS: enable autowire on the ECS client

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 f99c6a8588f838acf1509c6ecc0a4e349505b5be
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Nov 16 07:53:39 2020 +0100

    CAMEL-15836 - Camel-AWS2-ECS: enable autowire on the ECS client
---
 .../apache/camel/component/aws2/ecs/ECS2Component.java | 18 ------------------
 .../camel/component/aws2/ecs/ECS2Configuration.java    | 15 +--------------
 2 files changed, 1 insertion(+), 32 deletions(-)

diff --git a/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Component.java b/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Component.java
index 377d31d..4d726a1 100644
--- a/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Component.java
+++ b/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Component.java
@@ -55,9 +55,6 @@ public class ECS2Component extends DefaultComponent {
         ECS2Configuration configuration = this.configuration != null ? this.configuration.copy() : new ECS2Configuration();
         ECS2Endpoint endpoint = new ECS2Endpoint(uri, this, configuration);
         setProperties(endpoint, parameters);
-        if (endpoint.getConfiguration().isAutoDiscoverClient()) {
-            checkAndSetRegistryClient(configuration, endpoint);
-        }
         if (configuration.getEcsClient() == null
                 && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
             throw new IllegalArgumentException("Amazon ecs client or accessKey and secretKey must be specified");
@@ -76,19 +73,4 @@ public class ECS2Component extends DefaultComponent {
     public void setConfiguration(ECS2Configuration configuration) {
         this.configuration = configuration;
     }
-
-    private void checkAndSetRegistryClient(ECS2Configuration configuration, ECS2Endpoint endpoint) {
-        if (ObjectHelper.isEmpty(endpoint.getConfiguration().getEcsClient())) {
-            LOG.debug("Looking for an EcsClient instance in the registry");
-            Set<EcsClient> clients = getCamelContext().getRegistry().findByType(EcsClient.class);
-            if (clients.size() == 1) {
-                LOG.debug("Found exactly one EcsClient instance in the registry");
-                configuration.setEcsClient(clients.stream().findFirst().get());
-            } else {
-                LOG.debug("No EcsClient instance in the registry");
-            }
-        } else {
-            LOG.debug("EcsClient instance is already set at endpoint level: skipping the check in the registry");
-        }
-    }
 }
diff --git a/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Configuration.java b/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Configuration.java
index a093577..20af541 100644
--- a/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Configuration.java
+++ b/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Configuration.java
@@ -31,6 +31,7 @@ public class ECS2Configuration implements Cloneable {
     @Metadata(required = true)
     private String label;
     @UriParam
+    @Metadata(autowired = true)
     private EcsClient ecsClient;
     @UriParam(label = "security", secret = true)
     private String accessKey;
@@ -51,8 +52,6 @@ public class ECS2Configuration implements Cloneable {
     private boolean pojoRequest;
     @UriParam(defaultValue = "false")
     private boolean trustAllCertificates;
-    @UriParam(label = "common", defaultValue = "true")
-    private boolean autoDiscoverClient = true;
 
     public EcsClient getEcsClient() {
         return ecsClient;
@@ -165,18 +164,6 @@ public class ECS2Configuration 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;
-    }
-
     // *************************************************
     //
     // *************************************************