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/07/28 06:50:57 UTC

[camel] 01/06: CAMEL-15310 - AWS* - Support for more than 1 client in the registry - Camel-AWS-Translate

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 23c9db63def650e1b975b36b378218bd18d2139b
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Jul 28 08:27:25 2020 +0200

    CAMEL-15310 - AWS* - Support for more than 1 client in the registry - Camel-AWS-Translate
---
 .../translate/TranslateComponentConfigurer.java    |  5 ++++
 .../aws/translate/TranslateEndpointConfigurer.java |  5 ++++
 .../component/aws/translate/aws-translate.json     |  2 ++
 .../src/main/docs/aws-translate-component.adoc     |  6 +++--
 .../aws/translate/TranslateComponent.java          |  4 ++-
 .../aws/translate/TranslateConfiguration.java      | 15 +++++++++++
 .../dsl/AwsTranslateComponentBuilderFactory.java   | 16 ++++++++++++
 .../dsl/TranslateEndpointBuilderFactory.java       | 30 ++++++++++++++++++++++
 8 files changed, 80 insertions(+), 3 deletions(-)

diff --git a/components/camel-aws-translate/src/generated/java/org/apache/camel/component/aws/translate/TranslateComponentConfigurer.java b/components/camel-aws-translate/src/generated/java/org/apache/camel/component/aws/translate/TranslateComponentConfigurer.java
index dadd33b..ece92a5 100644
--- a/components/camel-aws-translate/src/generated/java/org/apache/camel/component/aws/translate/TranslateComponentConfigurer.java
+++ b/components/camel-aws-translate/src/generated/java/org/apache/camel/component/aws/translate/TranslateComponentConfigurer.java
@@ -28,6 +28,8 @@ public class TranslateComponentConfigurer extends PropertyConfigurerSupport impl
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "accesskey":
         case "accessKey": getOrCreateConfiguration(target).setAccessKey(property(camelContext, java.lang.String.class, value)); return true;
+        case "autodiscoverclient":
+        case "autoDiscoverClient": getOrCreateConfiguration(target).setAutoDiscoverClient(property(camelContext, boolean.class, value)); return true;
         case "autodetectsourcelanguage":
         case "autodetectSourceLanguage": getOrCreateConfiguration(target).setAutodetectSourceLanguage(property(camelContext, boolean.class, value)); return true;
         case "basicpropertybinding":
@@ -59,6 +61,7 @@ public class TranslateComponentConfigurer extends PropertyConfigurerSupport impl
     public Map<String, Object> getAllOptions(Object target) {
         Map<String, Object> answer = new CaseInsensitiveMap();
         answer.put("accessKey", java.lang.String.class);
+        answer.put("autoDiscoverClient", boolean.class);
         answer.put("autodetectSourceLanguage", boolean.class);
         answer.put("basicPropertyBinding", boolean.class);
         answer.put("configuration", org.apache.camel.component.aws.translate.TranslateConfiguration.class);
@@ -81,6 +84,8 @@ public class TranslateComponentConfigurer extends PropertyConfigurerSupport impl
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "accesskey":
         case "accessKey": return getOrCreateConfiguration(target).getAccessKey();
+        case "autodiscoverclient":
+        case "autoDiscoverClient": return getOrCreateConfiguration(target).isAutoDiscoverClient();
         case "autodetectsourcelanguage":
         case "autodetectSourceLanguage": return getOrCreateConfiguration(target).isAutodetectSourceLanguage();
         case "basicpropertybinding":
diff --git a/components/camel-aws-translate/src/generated/java/org/apache/camel/component/aws/translate/TranslateEndpointConfigurer.java b/components/camel-aws-translate/src/generated/java/org/apache/camel/component/aws/translate/TranslateEndpointConfigurer.java
index e521cb0..320f77d 100644
--- a/components/camel-aws-translate/src/generated/java/org/apache/camel/component/aws/translate/TranslateEndpointConfigurer.java
+++ b/components/camel-aws-translate/src/generated/java/org/apache/camel/component/aws/translate/TranslateEndpointConfigurer.java
@@ -21,6 +21,8 @@ public class TranslateEndpointConfigurer extends PropertyConfigurerSupport imple
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "accesskey":
         case "accessKey": target.getConfiguration().setAccessKey(property(camelContext, java.lang.String.class, value)); return true;
+        case "autodiscoverclient":
+        case "autoDiscoverClient": target.getConfiguration().setAutoDiscoverClient(property(camelContext, boolean.class, value)); return true;
         case "autodetectsourcelanguage":
         case "autodetectSourceLanguage": target.getConfiguration().setAutodetectSourceLanguage(property(camelContext, boolean.class, value)); return true;
         case "basicpropertybinding":
@@ -52,6 +54,7 @@ public class TranslateEndpointConfigurer extends PropertyConfigurerSupport imple
     public Map<String, Object> getAllOptions(Object target) {
         Map<String, Object> answer = new CaseInsensitiveMap();
         answer.put("accessKey", java.lang.String.class);
+        answer.put("autoDiscoverClient", boolean.class);
         answer.put("autodetectSourceLanguage", boolean.class);
         answer.put("basicPropertyBinding", boolean.class);
         answer.put("lazyStartProducer", boolean.class);
@@ -74,6 +77,8 @@ public class TranslateEndpointConfigurer extends PropertyConfigurerSupport imple
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "accesskey":
         case "accessKey": return target.getConfiguration().getAccessKey();
+        case "autodiscoverclient":
+        case "autoDiscoverClient": return target.getConfiguration().isAutoDiscoverClient();
         case "autodetectsourcelanguage":
         case "autodetectSourceLanguage": return target.getConfiguration().isAutodetectSourceLanguage();
         case "basicpropertybinding":
diff --git a/components/camel-aws-translate/src/generated/resources/org/apache/camel/component/aws/translate/aws-translate.json b/components/camel-aws-translate/src/generated/resources/org/apache/camel/component/aws/translate/aws-translate.json
index 04d21cc..4a2acf7 100644
--- a/components/camel-aws-translate/src/generated/resources/org/apache/camel/component/aws/translate/aws-translate.json
+++ b/components/camel-aws-translate/src/generated/resources/org/apache/camel/component/aws/translate/aws-translate.json
@@ -21,6 +21,7 @@
     "lenientProperties": false
   },
   "componentProperties": {
+    "autoDiscoverClient": { "kind": "property", "displayName": "Auto Discover Client", "group": "common", "label": "common", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "true", "configurationClass": "org.apache.camel.component.aws.translate.TranslateConfiguration", "configurationField": "configuration", "description": "Setting the autoDiscoverClient mechanism, if true, the component will look for a client instance in  [...]
     "accessKey": { "kind": "property", "displayName": "Access Key", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": true, "configurationClass": "org.apache.camel.component.aws.translate.TranslateConfiguration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
     "autodetectSourceLanguage": { "kind": "property", "displayName": "Autodetect Source Language", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "false", "configurationClass": "org.apache.camel.component.aws.translate.TranslateConfiguration", "configurationField": "configuration", "description": "Being able to autodetect the source language" },
     "configuration": { "kind": "property", "displayName": "Configuration", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.aws.translate.TranslateConfiguration", "deprecated": false, "secret": false, "description": "The component configuration" },
@@ -38,6 +39,7 @@
   },
   "properties": {
     "label": { "kind": "path", "displayName": "Label", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "secret": false, "configurationClass": "org.apache.camel.component.aws.translate.TranslateConfiguration", "configurationField": "configuration", "description": "Logical name" },
+    "autoDiscoverClient": { "kind": "parameter", "displayName": "Auto Discover Client", "group": "common", "label": "common", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "true", "configurationClass": "org.apache.camel.component.aws.translate.TranslateConfiguration", "configurationField": "configuration", "description": "Setting the autoDiscoverClient mechanism, if true, the component will look for a client instance in [...]
     "accessKey": { "kind": "parameter", "displayName": "Access Key", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": true, "configurationClass": "org.apache.camel.component.aws.translate.TranslateConfiguration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
     "autodetectSourceLanguage": { "kind": "parameter", "displayName": "Autodetect Source Language", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "false", "configurationClass": "org.apache.camel.component.aws.translate.TranslateConfiguration", "configurationField": "configuration", "description": "Being able to autodetect the source language" },
     "lazyStartProducer": { "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the  [...]
diff --git a/components/camel-aws-translate/src/main/docs/aws-translate-component.adoc b/components/camel-aws-translate/src/main/docs/aws-translate-component.adoc
index 1980366..229c6cd 100644
--- a/components/camel-aws-translate/src/main/docs/aws-translate-component.adoc
+++ b/components/camel-aws-translate/src/main/docs/aws-translate-component.adoc
@@ -36,13 +36,14 @@ You can append query options to the URI in the following format,
 
 
 // component options: START
-The AWS Translate component supports 14 options, which are listed below.
+The AWS Translate component supports 15 options, which are listed below.
 
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
+| *autoDiscoverClient* (common) | Setting the autoDiscoverClient mechanism, if true, the component will look for a client instance in the registry automatically otherwise it will skip that checking. | true | boolean
 | *accessKey* (producer) | Amazon AWS Access Key |  | String
 | *autodetectSourceLanguage* (producer) | Being able to autodetect the source language | false | boolean
 | *configuration* (producer) | The component configuration |  | TranslateConfiguration
@@ -82,12 +83,13 @@ with the following path and query parameters:
 |===
 
 
-=== Query Parameters (14 parameters):
+=== Query Parameters (15 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
+| *autoDiscoverClient* (common) | Setting the autoDiscoverClient mechanism, if true, the component will look for a client instance in the registry automatically otherwise it will skip that checking. | true | boolean
 | *accessKey* (producer) | Amazon AWS Access Key |  | String
 | *autodetectSourceLanguage* (producer) | Being able to autodetect the source language | false | boolean
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
diff --git a/components/camel-aws-translate/src/main/java/org/apache/camel/component/aws/translate/TranslateComponent.java b/components/camel-aws-translate/src/main/java/org/apache/camel/component/aws/translate/TranslateComponent.java
index 1a84b02..319ecfb 100644
--- a/components/camel-aws-translate/src/main/java/org/apache/camel/component/aws/translate/TranslateComponent.java
+++ b/components/camel-aws-translate/src/main/java/org/apache/camel/component/aws/translate/TranslateComponent.java
@@ -51,7 +51,9 @@ public class TranslateComponent extends DefaultComponent {
 
         TranslateEndpoint endpoint = new TranslateEndpoint(uri, this, configuration);
         setProperties(endpoint, parameters);
-        checkAndSetRegistryClient(configuration);
+        if (endpoint.getConfiguration().isAutoDiscoverClient()) {
+            checkAndSetRegistryClient(configuration);
+        }
         if (configuration.getTranslateClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
             throw new IllegalArgumentException("Amazon translate client or accessKey and secretKey must be specified");
         }
diff --git a/components/camel-aws-translate/src/main/java/org/apache/camel/component/aws/translate/TranslateConfiguration.java b/components/camel-aws-translate/src/main/java/org/apache/camel/component/aws/translate/TranslateConfiguration.java
index 7bf1356..c200910 100644
--- a/components/camel-aws-translate/src/main/java/org/apache/camel/component/aws/translate/TranslateConfiguration.java
+++ b/components/camel-aws-translate/src/main/java/org/apache/camel/component/aws/translate/TranslateConfiguration.java
@@ -53,6 +53,8 @@ public class TranslateConfiguration implements Cloneable {
     private String region;
     @UriParam(label = "producer", defaultValue = "false")
     private boolean autodetectSourceLanguage;
+    @UriParam(label = "common", defaultValue = "true")
+    private boolean autoDiscoverClient = true;
 
     public AmazonTranslate getTranslateClient() {
         return translateClient;
@@ -177,6 +179,19 @@ public class TranslateConfiguration implements Cloneable {
     public void setTargetLanguage(String targetLanguage) {
         this.targetLanguage = targetLanguage;
     }
+    
+    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;
+    }
 
     // *************************************************
     //
diff --git a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsTranslateComponentBuilderFactory.java b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsTranslateComponentBuilderFactory.java
index 63f337a..57e7833 100644
--- a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsTranslateComponentBuilderFactory.java
+++ b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsTranslateComponentBuilderFactory.java
@@ -49,6 +49,21 @@ public interface AwsTranslateComponentBuilderFactory {
             extends
                 ComponentBuilder<TranslateComponent> {
         /**
+         * Setting the autoDiscoverClient mechanism, if true, the component will
+         * look for a client instance in the registry automatically otherwise it
+         * will skip that checking.
+         * 
+         * The option is a: <code>boolean</code> type.
+         * 
+         * Default: true
+         * Group: common
+         */
+        default AwsTranslateComponentBuilder autoDiscoverClient(
+                boolean autoDiscoverClient) {
+            doSetProperty("autoDiscoverClient", autoDiscoverClient);
+            return this;
+        }
+        /**
          * Amazon AWS Access Key.
          * 
          * The option is a: <code>java.lang.String</code> type.
@@ -259,6 +274,7 @@ public interface AwsTranslateComponentBuilderFactory {
                 String name,
                 Object value) {
             switch (name) {
+            case "autoDiscoverClient": getOrCreateConfiguration((TranslateComponent) component).setAutoDiscoverClient((boolean) value); return true;
             case "accessKey": getOrCreateConfiguration((TranslateComponent) component).setAccessKey((java.lang.String) value); return true;
             case "autodetectSourceLanguage": getOrCreateConfiguration((TranslateComponent) component).setAutodetectSourceLanguage((boolean) value); return true;
             case "configuration": ((TranslateComponent) component).setConfiguration((org.apache.camel.component.aws.translate.TranslateConfiguration) value); return true;
diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/TranslateEndpointBuilderFactory.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/TranslateEndpointBuilderFactory.java
index c1ae2f3..2396c56 100644
--- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/TranslateEndpointBuilderFactory.java
+++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/TranslateEndpointBuilderFactory.java
@@ -38,6 +38,36 @@ public interface TranslateEndpointBuilderFactory {
             return (AdvancedTranslateEndpointBuilder) this;
         }
         /**
+         * Setting the autoDiscoverClient mechanism, if true, the component will
+         * look for a client instance in the registry automatically otherwise it
+         * will skip that checking.
+         * 
+         * The option is a: <code>boolean</code> type.
+         * 
+         * Default: true
+         * Group: common
+         */
+        default TranslateEndpointBuilder autoDiscoverClient(
+                boolean autoDiscoverClient) {
+            doSetProperty("autoDiscoverClient", autoDiscoverClient);
+            return this;
+        }
+        /**
+         * Setting the autoDiscoverClient mechanism, if true, the component will
+         * look for a client instance in the registry automatically otherwise it
+         * will skip that checking.
+         * 
+         * The option will be converted to a <code>boolean</code> type.
+         * 
+         * Default: true
+         * Group: common
+         */
+        default TranslateEndpointBuilder autoDiscoverClient(
+                String autoDiscoverClient) {
+            doSetProperty("autoDiscoverClient", autoDiscoverClient);
+            return this;
+        }
+        /**
          * Amazon AWS Access Key.
          * 
          * The option is a: <code>java.lang.String</code> type.