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/17 07:44:34 UTC

[camel] 01/06: CAMEL-15836 - Camel-AWS2-Lambda: enable autowire on the Lambda 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 62c2e5178f6d2b8c0ab2a6258b0c8092e9b93c4a
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Nov 17 08:21:36 2020 +0100

    CAMEL-15836 - Camel-AWS2-Lambda: enable autowire on the Lambda Client
---
 .../camel/component/aws2/lambda/Lambda2Component.java  | 18 ------------------
 .../component/aws2/lambda/Lambda2Configuration.java    | 16 ++--------------
 2 files changed, 2 insertions(+), 32 deletions(-)

diff --git a/components/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Component.java b/components/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Component.java
index 699e19a..b7f0fbb 100644
--- a/components/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Component.java
+++ b/components/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Component.java
@@ -57,9 +57,6 @@ public class Lambda2Component extends DefaultComponent {
         Lambda2Endpoint endpoint = new Lambda2Endpoint(uri, this, configuration);
         setProperties(endpoint, parameters);
         endpoint.setFunction(remaining);
-        if (endpoint.getConfiguration().isAutoDiscoverClient()) {
-            checkAndSetRegistryClient(configuration, endpoint);
-        }
         if (configuration.getAwsLambdaClient() == null
                 && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
             throw new IllegalArgumentException("accessKey/secretKey or awsLambdaClient must be specified");
@@ -78,19 +75,4 @@ public class Lambda2Component extends DefaultComponent {
     public void setConfiguration(Lambda2Configuration configuration) {
         this.configuration = configuration;
     }
-
-    private void checkAndSetRegistryClient(Lambda2Configuration configuration, Lambda2Endpoint endpoint) {
-        if (ObjectHelper.isEmpty(endpoint.getConfiguration().getAwsLambdaClient())) {
-            LOG.debug("Looking for an LambdaClient instance in the registry");
-            Set<LambdaClient> clients = getCamelContext().getRegistry().findByType(LambdaClient.class);
-            if (clients.size() == 1) {
-                LOG.debug("Found exactly one LambdaClient instance in the registry");
-                configuration.setAwsLambdaClient(clients.stream().findFirst().get());
-            } else {
-                LOG.debug("No LambdaClient instance in the registry");
-            }
-        } else {
-            LOG.debug("LambdaClient instance is already set at endpoint level: skipping the check in the registry");
-        }
-    }
 }
diff --git a/components/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Configuration.java b/components/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Configuration.java
index 122c1a8..6873aad 100644
--- a/components/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Configuration.java
+++ b/components/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Configuration.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.aws2.lambda;
 
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
 import software.amazon.awssdk.core.Protocol;
@@ -40,13 +41,12 @@ public class Lambda2Configuration implements Cloneable {
     @UriParam(label = "proxy")
     private Integer proxyPort;
     @UriParam(label = "advanced")
+    @Metadata(autowired = true)
     private LambdaClient awsLambdaClient;
     @UriParam(defaultValue = "false")
     private boolean pojoRequest;
     @UriParam(defaultValue = "false")
     private boolean trustAllCertificates;
-    @UriParam(label = "common", defaultValue = "true")
-    private boolean autoDiscoverClient = true;
 
     public LambdaClient getAwsLambdaClient() {
         return awsLambdaClient;
@@ -159,18 +159,6 @@ public class Lambda2Configuration 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;
-    }
-
     // *************************************************
     //
     // *************************************************