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/03/16 09:17:05 UTC

[camel] branch master updated (7926de1 -> d2556f4)

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 7926de1  Upgrade Jasn to version 1.11.3
     new 6f6e965  CAMEL-14690 - Camel-AWS2: Better logging when checking client instance in the registry, Translate
     new d2556f4  Camel-AWS2-Translate: Fixed CS

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../aws2/translate/Translate2Component.java        | 23 +++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)


[camel] 01/02: CAMEL-14690 - Camel-AWS2: Better logging when checking client instance in the registry, Translate

Posted by ac...@apache.org.
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 6f6e965b284bfbe89fda77473387b0c3659ecc19
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Mar 16 10:14:14 2020 +0100

    CAMEL-14690 - Camel-AWS2: Better logging when checking client instance in the registry, Translate
---
 .../aws2/translate/Translate2Component.java        | 24 +++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/components/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Component.java b/components/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Component.java
index c9e6243..ce5651e 100644
--- a/components/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Component.java
+++ b/components/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Component.java
@@ -24,6 +24,10 @@ import org.apache.camel.Endpoint;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.annotations.Component;
 import org.apache.camel.support.DefaultComponent;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import software.amazon.awssdk.services.translate.TranslateClient;
 
 /**
@@ -31,6 +35,8 @@ import software.amazon.awssdk.services.translate.TranslateClient;
  */
 @Component("aws2-translate")
 public class Translate2Component extends DefaultComponent {
+	
+    private static final Logger LOG = LoggerFactory.getLogger(Translate2Component.class);
 
     @Metadata
     private Translate2Configuration configuration = new Translate2Configuration();
@@ -51,7 +57,7 @@ public class Translate2Component extends DefaultComponent {
 
         Translate2Endpoint endpoint = new Translate2Endpoint(uri, this, configuration);
         setProperties(endpoint, parameters);
-        checkAndSetRegistryClient(configuration);
+        checkAndSetRegistryClient(configuration, endpoint);
         if (configuration.getTranslateClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
             throw new IllegalArgumentException("Amazon translate client or accessKey and secretKey must be specified");
         }
@@ -69,10 +75,18 @@ public class Translate2Component extends DefaultComponent {
         this.configuration = configuration;
     }
 
-    private void checkAndSetRegistryClient(Translate2Configuration configuration) {
-        Set<TranslateClient> clients = getCamelContext().getRegistry().findByType(TranslateClient.class);
-        if (clients.size() == 1) {
-            configuration.setTranslateClient(clients.stream().findFirst().get());
+    private void checkAndSetRegistryClient(Translate2Configuration configuration, Translate2Endpoint endpoint) {
+        if (ObjectHelper.isEmpty(endpoint.getConfiguration().getTranslateClient())) {
+            LOG.debug("Looking for an TranslateClient instance in the registry");
+            Set<TranslateClient> clients = getCamelContext().getRegistry().findByType(TranslateClient.class);
+            if (clients.size() == 1) {
+                LOG.debug("Found exactly one TranslateClient instance in the registry");
+                configuration.setTranslateClient(clients.stream().findFirst().get());
+            } else {
+                LOG.debug("No TranslateClient instance in the registry");
+            }
+        } else {
+            LOG.debug("TranslateClient instance is already set at endpoint level: skipping the check in the registry");
         }
     }
 }


[camel] 02/02: Camel-AWS2-Translate: Fixed CS

Posted by ac...@apache.org.
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 d2556f40f6d47e76367d46668884008fcd004a26
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Mar 16 10:16:06 2020 +0100

    Camel-AWS2-Translate: Fixed CS
---
 .../org/apache/camel/component/aws2/translate/Translate2Component.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/components/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Component.java b/components/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Component.java
index ce5651e..ab6a361 100644
--- a/components/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Component.java
+++ b/components/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Component.java
@@ -27,7 +27,6 @@ import org.apache.camel.support.DefaultComponent;
 import org.apache.camel.util.ObjectHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
 import software.amazon.awssdk.services.translate.TranslateClient;
 
 /**
@@ -35,7 +34,7 @@ import software.amazon.awssdk.services.translate.TranslateClient;
  */
 @Component("aws2-translate")
 public class Translate2Component extends DefaultComponent {
-	
+
     private static final Logger LOG = LoggerFactory.getLogger(Translate2Component.class);
 
     @Metadata