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 120a76fb11cd62f659e645541f25ec1ef89cecd5 Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Tue Jul 28 08:48:12 2020 +0200 CAMEL-15310 - AWS* - Support for more than 1 client in the registry - Camel-AWS2-Translate --- .../translate/Translate2ComponentConfigurer.java | 5 ++++ .../translate/Translate2EndpointConfigurer.java | 5 ++++ .../component/aws2/translate/aws2-translate.json | 2 ++ .../src/main/docs/aws2-translate-component.adoc | 6 +++-- .../aws2/translate/Translate2Component.java | 4 ++- .../aws2/translate/Translate2Configuration.java | 15 +++++++++++ .../dsl/Aws2TranslateComponentBuilderFactory.java | 16 ++++++++++++ .../dsl/Translate2EndpointBuilderFactory.java | 30 ++++++++++++++++++++++ 8 files changed, 80 insertions(+), 3 deletions(-) diff --git a/components/camel-aws2-translate/src/generated/java/org/apache/camel/component/aws2/translate/Translate2ComponentConfigurer.java b/components/camel-aws2-translate/src/generated/java/org/apache/camel/component/aws2/translate/Translate2ComponentConfigurer.java index 2d86142..4223f03 100644 --- a/components/camel-aws2-translate/src/generated/java/org/apache/camel/component/aws2/translate/Translate2ComponentConfigurer.java +++ b/components/camel-aws2-translate/src/generated/java/org/apache/camel/component/aws2/translate/Translate2ComponentConfigurer.java @@ -28,6 +28,8 @@ public class Translate2ComponentConfigurer extends PropertyConfigurerSupport imp 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": @@ -63,6 +65,7 @@ public class Translate2ComponentConfigurer extends PropertyConfigurerSupport imp 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.aws2.translate.Translate2Configuration.class); @@ -87,6 +90,8 @@ public class Translate2ComponentConfigurer extends PropertyConfigurerSupport imp 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-aws2-translate/src/generated/java/org/apache/camel/component/aws2/translate/Translate2EndpointConfigurer.java b/components/camel-aws2-translate/src/generated/java/org/apache/camel/component/aws2/translate/Translate2EndpointConfigurer.java index 1f95931..46881e7 100644 --- a/components/camel-aws2-translate/src/generated/java/org/apache/camel/component/aws2/translate/Translate2EndpointConfigurer.java +++ b/components/camel-aws2-translate/src/generated/java/org/apache/camel/component/aws2/translate/Translate2EndpointConfigurer.java @@ -21,6 +21,8 @@ public class Translate2EndpointConfigurer extends PropertyConfigurerSupport impl 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": @@ -56,6 +58,7 @@ public class Translate2EndpointConfigurer 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("lazyStartProducer", boolean.class); @@ -80,6 +83,8 @@ public class Translate2EndpointConfigurer extends PropertyConfigurerSupport impl 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-aws2-translate/src/generated/resources/org/apache/camel/component/aws2/translate/aws2-translate.json b/components/camel-aws2-translate/src/generated/resources/org/apache/camel/component/aws2/translate/aws2-translate.json index 2198d5f..9ceee5a 100644 --- a/components/camel-aws2-translate/src/generated/resources/org/apache/camel/component/aws2/translate/aws2-translate.json +++ b/components/camel-aws2-translate/src/generated/resources/org/apache/camel/component/aws2/translate/aws2-translate.json @@ -22,6 +22,7 @@ }, "componentProperties": { "autodetectSourceLanguage": { "kind": "property", "displayName": "Autodetect Source Language", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "false", "configurationClass": "org.apache.camel.component.aws2.translate.Translate2Configuration", "configurationField": "configuration", "description": "Being able to autodetect the source language" }, + "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.aws2.translate.Translate2Configuration", "configurationField": "configuration", "description": "Setting the autoDiscoverClient mechanism, if true, the component will look for a client instance i [...] "configuration": { "kind": "property", "displayName": "Configuration", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.aws2.translate.Translate2Configuration", "deprecated": false, "secret": false, "description": "Component configuration" }, "lazyStartProducer": { "kind": "property", "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 r [...] "operation": { "kind": "property", "displayName": "Operation", "group": "producer", "label": "", "required": true, "type": "object", "javaType": "org.apache.camel.component.aws2.translate.Translate2Operations", "enum": [ "translateText" ], "deprecated": false, "deprecationNote": "", "secret": false, "defaultValue": "translateText", "configurationClass": "org.apache.camel.component.aws2.translate.Translate2Configuration", "configurationField": "configuration", "description": "The oper [...] @@ -41,6 +42,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.aws2.translate.Translate2Configuration", "configurationField": "configuration", "description": "Logical name" }, "autodetectSourceLanguage": { "kind": "parameter", "displayName": "Autodetect Source Language", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "false", "configurationClass": "org.apache.camel.component.aws2.translate.Translate2Configuration", "configurationField": "configuration", "description": "Being able to autodetect the source language" }, + "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.aws2.translate.Translate2Configuration", "configurationField": "configuration", "description": "Setting the autoDiscoverClient mechanism, if true, the component will look for a client instance [...] "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 [...] "operation": { "kind": "parameter", "displayName": "Operation", "group": "producer", "label": "", "required": true, "type": "object", "javaType": "org.apache.camel.component.aws2.translate.Translate2Operations", "enum": [ "translateText" ], "deprecated": false, "deprecationNote": "", "secret": false, "defaultValue": "translateText", "configurationClass": "org.apache.camel.component.aws2.translate.Translate2Configuration", "configurationField": "configuration", "description": "The ope [...] "pojoRequest": { "kind": "parameter", "displayName": "Pojo Request", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "false", "configurationClass": "org.apache.camel.component.aws2.translate.Translate2Configuration", "configurationField": "configuration", "description": "If we want to use a POJO request as body or not" }, diff --git a/components/camel-aws2-translate/src/main/docs/aws2-translate-component.adoc b/components/camel-aws2-translate/src/main/docs/aws2-translate-component.adoc index ad9edb5..2ed4bec 100644 --- a/components/camel-aws2-translate/src/main/docs/aws2-translate-component.adoc +++ b/components/camel-aws2-translate/src/main/docs/aws2-translate-component.adoc @@ -41,7 +41,7 @@ You can append query options to the URI in the following format, // component options: START -The AWS 2 Translate component supports 16 options, which are listed below. +The AWS 2 Translate component supports 17 options, which are listed below. @@ -49,6 +49,7 @@ The AWS 2 Translate component supports 16 options, which are listed below. |=== | Name | Description | Default | Type | *autodetectSourceLanguage* (producer) | Being able to autodetect the source language | false | boolean +| *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 | *configuration* (producer) | Component configuration | | Translate2Configuration | *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 [...] | *operation* (producer) | *Required* The operation to perform. The value can be one of: translateText | translateText | Translate2Operations @@ -89,13 +90,14 @@ with the following path and query parameters: |=== -=== Query Parameters (16 parameters): +=== Query Parameters (17 parameters): [width="100%",cols="2,5,^1,2",options="header"] |=== | Name | Description | Default | Type | *autodetectSourceLanguage* (producer) | Being able to autodetect the source language | false | boolean +| *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 | *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 [...] | *operation* (producer) | *Required* The operation to perform. The value can be one of: translateText | translateText | Translate2Operations | *pojoRequest* (producer) | If we want to use a POJO request as body or not | false | boolean 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 ab6a361..22b02fe 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 @@ -56,7 +56,9 @@ public class Translate2Component extends DefaultComponent { Translate2Endpoint endpoint = new Translate2Endpoint(uri, this, configuration); setProperties(endpoint, parameters); - checkAndSetRegistryClient(configuration, endpoint); + if (endpoint.getConfiguration().isAutoDiscoverClient()) { + 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"); } diff --git a/components/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Configuration.java b/components/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Configuration.java index 52ee0e8..aa78230 100644 --- a/components/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Configuration.java +++ b/components/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Configuration.java @@ -57,6 +57,8 @@ public class Translate2Configuration implements Cloneable { private boolean pojoRequest; @UriParam(defaultValue = "false") private boolean trustAllCertificates; + @UriParam(label = "common", defaultValue = "true") + private boolean autoDiscoverClient = true; public TranslateClient getTranslateClient() { return translateClient; @@ -202,6 +204,19 @@ public class Translate2Configuration implements Cloneable { public void setTrustAllCertificates(boolean trustAllCertificates) { 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; + } // ************************************************* // diff --git a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2TranslateComponentBuilderFactory.java b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2TranslateComponentBuilderFactory.java index 595bb04..9364037 100644 --- a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2TranslateComponentBuilderFactory.java +++ b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2TranslateComponentBuilderFactory.java @@ -62,6 +62,21 @@ public interface Aws2TranslateComponentBuilderFactory { 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 is a: <code>boolean</code> type. + * + * Default: true + * Group: common + */ + default Aws2TranslateComponentBuilder autoDiscoverClient( + boolean autoDiscoverClient) { + doSetProperty("autoDiscoverClient", autoDiscoverClient); + return this; + } + /** * Component configuration. * * The option is a: @@ -287,6 +302,7 @@ public interface Aws2TranslateComponentBuilderFactory { Object value) { switch (name) { case "autodetectSourceLanguage": getOrCreateConfiguration((Translate2Component) component).setAutodetectSourceLanguage((boolean) value); return true; + case "autoDiscoverClient": getOrCreateConfiguration((Translate2Component) component).setAutoDiscoverClient((boolean) value); return true; case "configuration": ((Translate2Component) component).setConfiguration((org.apache.camel.component.aws2.translate.Translate2Configuration) value); return true; case "lazyStartProducer": ((Translate2Component) component).setLazyStartProducer((boolean) value); return true; case "operation": getOrCreateConfiguration((Translate2Component) component).setOperation((org.apache.camel.component.aws2.translate.Translate2Operations) value); return true; diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Translate2EndpointBuilderFactory.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Translate2EndpointBuilderFactory.java index ad4ae8b..bd40b7e 100644 --- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Translate2EndpointBuilderFactory.java +++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Translate2EndpointBuilderFactory.java @@ -66,6 +66,36 @@ public interface Translate2EndpointBuilderFactory { 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 is a: <code>boolean</code> type. + * + * Default: true + * Group: common + */ + default Translate2EndpointBuilder 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 Translate2EndpointBuilder autoDiscoverClient( + String autoDiscoverClient) { + doSetProperty("autoDiscoverClient", autoDiscoverClient); + return this; + } + /** * 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