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 13:52:42 UTC

[camel] 01/05: CAMEL-15836 - Camel-AWS2-EC2: enable autowire on the Ec2 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 226ca0e774eeef0f4282e9ab927e4009ef4677b9
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Nov 13 14:14:05 2020 +0100

    CAMEL-15836 - Camel-AWS2-EC2: enable autowire on the Ec2 client
---
 .../camel/component/aws2/ec2/AWS2EC2Component.java     | 18 ------------------
 .../camel/component/aws2/ec2/AWS2EC2Configuration.java | 15 +--------------
 2 files changed, 1 insertion(+), 32 deletions(-)

diff --git a/components/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Component.java b/components/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Component.java
index 6a60c6e..83e941b 100644
--- a/components/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Component.java
+++ b/components/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Component.java
@@ -57,9 +57,6 @@ public class AWS2EC2Component extends DefaultComponent {
                 = this.configuration != null ? this.configuration.copy() : new AWS2EC2Configuration();
         AWS2EC2Endpoint endpoint = new AWS2EC2Endpoint(uri, this, configuration);
         setProperties(endpoint, parameters);
-        if (endpoint.getConfiguration().isAutoDiscoverClient()) {
-            checkAndSetRegistryClient(configuration, endpoint);
-        }
         if (configuration.getAmazonEc2Client() == null
                 && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
             throw new IllegalArgumentException("amazonEC2Client or accessKey and secretKey must be specified");
@@ -78,19 +75,4 @@ public class AWS2EC2Component extends DefaultComponent {
     public void setConfiguration(AWS2EC2Configuration configuration) {
         this.configuration = configuration;
     }
-
-    private void checkAndSetRegistryClient(AWS2EC2Configuration configuration, AWS2EC2Endpoint endpoint) {
-        if (ObjectHelper.isEmpty(endpoint.getConfiguration().getAmazonEc2Client())) {
-            LOG.debug("Looking for an Ec2Client instance in the registry");
-            Set<Ec2Client> clients = getCamelContext().getRegistry().findByType(Ec2Client.class);
-            if (clients.size() == 1) {
-                LOG.debug("Found exactly one Ec2Client instance in the registry");
-                configuration.setAmazonEc2Client(clients.stream().findFirst().get());
-            } else {
-                LOG.debug("No Ec2Client instance in the registry");
-            }
-        } else {
-            LOG.debug("Ec2Client instance is already set at endpoint level: skipping the check in the registry");
-        }
-    }
 }
diff --git a/components/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Configuration.java b/components/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Configuration.java
index ccc83d5..348108e 100644
--- a/components/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Configuration.java
+++ b/components/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Configuration.java
@@ -31,6 +31,7 @@ public class AWS2EC2Configuration implements Cloneable {
     @Metadata(required = true)
     private String label;
     @UriParam(label = "producer")
+    @Metadata(autowired = true)
     private Ec2Client amazonEc2Client;
     @UriParam(label = "producer", secret = true)
     private String accessKey;
@@ -51,8 +52,6 @@ public class AWS2EC2Configuration implements Cloneable {
     private boolean pojoRequest;
     @UriParam(defaultValue = "false")
     private boolean trustAllCertificates;
-    @UriParam(label = "common", defaultValue = "true")
-    private boolean autoDiscoverClient = true;
 
     public Ec2Client getAmazonEc2Client() {
         return amazonEc2Client;
@@ -167,18 +166,6 @@ public class AWS2EC2Configuration 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;
-    }
-
     // *************************************************
     //
     // *************************************************