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 7034c86771eff15e3817a91214e5941181985410 Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Thu Jul 23 09:03:18 2020 +0200 CAMEL-15310 - AWS* - Support for more than 1 client in the registry - Camel-AWS2-Kinesis Firehose --- .../KinesisFirehose2ComponentConfigurer.java | 5 ++++ .../KinesisFirehose2EndpointConfigurer.java | 5 ++++ .../aws2/firehose/aws2-kinesis-firehose.json | 2 ++ .../main/docs/aws2-kinesis-firehose-component.adoc | 6 +++-- .../aws2/firehose/KinesisFirehose2Component.java | 4 ++- .../firehose/KinesisFirehose2Configuration.java | 11 ++++++++ .../KinesisFirehoseComponentConfigurationTest.java | 11 ++++++++ ...Aws2KinesisFirehoseComponentBuilderFactory.java | 16 ++++++++++++ .../KinesisFirehose2EndpointBuilderFactory.java | 30 ++++++++++++++++++++++ 9 files changed, 87 insertions(+), 3 deletions(-) diff --git a/components/camel-aws2-kinesis/src/generated/java/org/apache/camel/component/aws2/firehose/KinesisFirehose2ComponentConfigurer.java b/components/camel-aws2-kinesis/src/generated/java/org/apache/camel/component/aws2/firehose/KinesisFirehose2ComponentConfigurer.java index 111be7d..5144a27 100644 --- a/components/camel-aws2-kinesis/src/generated/java/org/apache/camel/component/aws2/firehose/KinesisFirehose2ComponentConfigurer.java +++ b/components/camel-aws2-kinesis/src/generated/java/org/apache/camel/component/aws2/firehose/KinesisFirehose2ComponentConfigurer.java @@ -30,6 +30,8 @@ public class KinesisFirehose2ComponentConfigurer extends PropertyConfigurerSuppo case "accessKey": getOrCreateConfiguration(target).setAccessKey(property(camelContext, java.lang.String.class, value)); return true; case "amazonkinesisfirehoseclient": case "amazonKinesisFirehoseClient": getOrCreateConfiguration(target).setAmazonKinesisFirehoseClient(property(camelContext, software.amazon.awssdk.services.firehose.FirehoseClient.class, value)); return true; + case "autodiscoverclient": + case "autoDiscoverClient": getOrCreateConfiguration(target).setAutoDiscoverClient(property(camelContext, boolean.class, value)); return true; case "basicpropertybinding": case "basicPropertyBinding": target.setBasicPropertyBinding(property(camelContext, boolean.class, value)); return true; case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.aws2.firehose.KinesisFirehose2Configuration.class, value)); return true; @@ -56,6 +58,7 @@ public class KinesisFirehose2ComponentConfigurer extends PropertyConfigurerSuppo Map<String, Object> answer = new CaseInsensitiveMap(); answer.put("accessKey", java.lang.String.class); answer.put("amazonKinesisFirehoseClient", software.amazon.awssdk.services.firehose.FirehoseClient.class); + answer.put("autoDiscoverClient", boolean.class); answer.put("basicPropertyBinding", boolean.class); answer.put("configuration", org.apache.camel.component.aws2.firehose.KinesisFirehose2Configuration.class); answer.put("lazyStartProducer", boolean.class); @@ -77,6 +80,8 @@ public class KinesisFirehose2ComponentConfigurer extends PropertyConfigurerSuppo case "accessKey": return getOrCreateConfiguration(target).getAccessKey(); case "amazonkinesisfirehoseclient": case "amazonKinesisFirehoseClient": return getOrCreateConfiguration(target).getAmazonKinesisFirehoseClient(); + case "autodiscoverclient": + case "autoDiscoverClient": return getOrCreateConfiguration(target).isAutoDiscoverClient(); case "basicpropertybinding": case "basicPropertyBinding": return target.isBasicPropertyBinding(); case "configuration": return target.getConfiguration(); diff --git a/components/camel-aws2-kinesis/src/generated/java/org/apache/camel/component/aws2/firehose/KinesisFirehose2EndpointConfigurer.java b/components/camel-aws2-kinesis/src/generated/java/org/apache/camel/component/aws2/firehose/KinesisFirehose2EndpointConfigurer.java index a5b2d75..5169b2a 100644 --- a/components/camel-aws2-kinesis/src/generated/java/org/apache/camel/component/aws2/firehose/KinesisFirehose2EndpointConfigurer.java +++ b/components/camel-aws2-kinesis/src/generated/java/org/apache/camel/component/aws2/firehose/KinesisFirehose2EndpointConfigurer.java @@ -23,6 +23,8 @@ public class KinesisFirehose2EndpointConfigurer extends PropertyConfigurerSuppor case "accessKey": target.getConfiguration().setAccessKey(property(camelContext, java.lang.String.class, value)); return true; case "amazonkinesisfirehoseclient": case "amazonKinesisFirehoseClient": target.getConfiguration().setAmazonKinesisFirehoseClient(property(camelContext, software.amazon.awssdk.services.firehose.FirehoseClient.class, value)); return true; + case "autodiscoverclient": + case "autoDiscoverClient": target.getConfiguration().setAutoDiscoverClient(property(camelContext, boolean.class, value)); return true; case "basicpropertybinding": case "basicPropertyBinding": target.setBasicPropertyBinding(property(camelContext, boolean.class, value)); return true; case "lazystartproducer": @@ -49,6 +51,7 @@ public class KinesisFirehose2EndpointConfigurer extends PropertyConfigurerSuppor Map<String, Object> answer = new CaseInsensitiveMap(); answer.put("accessKey", java.lang.String.class); answer.put("amazonKinesisFirehoseClient", software.amazon.awssdk.services.firehose.FirehoseClient.class); + answer.put("autoDiscoverClient", boolean.class); answer.put("basicPropertyBinding", boolean.class); answer.put("lazyStartProducer", boolean.class); answer.put("operation", org.apache.camel.component.aws2.firehose.KinesisFirehose2Operations.class); @@ -70,6 +73,8 @@ public class KinesisFirehose2EndpointConfigurer extends PropertyConfigurerSuppor case "accessKey": return target.getConfiguration().getAccessKey(); case "amazonkinesisfirehoseclient": case "amazonKinesisFirehoseClient": return target.getConfiguration().getAmazonKinesisFirehoseClient(); + case "autodiscoverclient": + case "autoDiscoverClient": return target.getConfiguration().isAutoDiscoverClient(); case "basicpropertybinding": case "basicPropertyBinding": return target.isBasicPropertyBinding(); case "lazystartproducer": diff --git a/components/camel-aws2-kinesis/src/generated/resources/org/apache/camel/component/aws2/firehose/aws2-kinesis-firehose.json b/components/camel-aws2-kinesis/src/generated/resources/org/apache/camel/component/aws2/firehose/aws2-kinesis-firehose.json index 0e0d89e..d922ee5 100644 --- a/components/camel-aws2-kinesis/src/generated/resources/org/apache/camel/component/aws2/firehose/aws2-kinesis-firehose.json +++ b/components/camel-aws2-kinesis/src/generated/resources/org/apache/camel/component/aws2/firehose/aws2-kinesis-firehose.json @@ -22,6 +22,7 @@ }, "componentProperties": { "amazonKinesisFirehoseClient": { "kind": "property", "displayName": "Amazon Kinesis Firehose Client", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.firehose.FirehoseClient", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.firehose.KinesisFirehose2Configuration", "configurationField": "configuration", "description": "Amazon Kinesis Firehose client to use for all requests [...] + "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.firehose.KinesisFirehose2Configuration", "configurationField": "configuration", "description": "Setting the autoDiscoverClient mechanism, if true, the component will look for a client insta [...] "configuration": { "kind": "property", "displayName": "Configuration", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.aws2.firehose.KinesisFirehose2Configuration", "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": "producer", "required": false, "type": "object", "javaType": "org.apache.camel.component.aws2.firehose.KinesisFirehose2Operations", "enum": [ "sendBatchRecord", "createDeliveryStream", "deleteDeliveryStream", "updateDestination" ], "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.firehose.KinesisFirehose2Configuration", "configurationField": "config [...] @@ -37,6 +38,7 @@ "properties": { "streamName": { "kind": "path", "displayName": "Stream Name", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "secret": false, "configurationClass": "org.apache.camel.component.aws2.firehose.KinesisFirehose2Configuration", "configurationField": "configuration", "description": "Name of the stream" }, "amazonKinesisFirehoseClient": { "kind": "parameter", "displayName": "Amazon Kinesis Firehose Client", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.firehose.FirehoseClient", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.firehose.KinesisFirehose2Configuration", "configurationField": "configuration", "description": "Amazon Kinesis Firehose client to use for all requests [...] + "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.firehose.KinesisFirehose2Configuration", "configurationField": "configuration", "description": "Setting the autoDiscoverClient mechanism, if true, the component will look for a client inst [...] "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": "producer", "required": false, "type": "object", "javaType": "org.apache.camel.component.aws2.firehose.KinesisFirehose2Operations", "enum": [ "sendBatchRecord", "createDeliveryStream", "deleteDeliveryStream", "updateDestination" ], "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.firehose.KinesisFirehose2Configuration", "configurationField": "confi [...] "proxyHost": { "kind": "parameter", "displayName": "Proxy Host", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.firehose.KinesisFirehose2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the Kinesis Firehose client" }, diff --git a/components/camel-aws2-kinesis/src/main/docs/aws2-kinesis-firehose-component.adoc b/components/camel-aws2-kinesis/src/main/docs/aws2-kinesis-firehose-component.adoc index d929813..8faaa23 100644 --- a/components/camel-aws2-kinesis/src/main/docs/aws2-kinesis-firehose-component.adoc +++ b/components/camel-aws2-kinesis/src/main/docs/aws2-kinesis-firehose-component.adoc @@ -41,7 +41,7 @@ The stream needs to be created prior to it being used. + // component options: START -The AWS 2 Kinesis Firehose component supports 12 options, which are listed below. +The AWS 2 Kinesis Firehose component supports 13 options, which are listed below. @@ -49,6 +49,7 @@ The AWS 2 Kinesis Firehose component supports 12 options, which are listed below |=== | Name | Description | Default | Type | *amazonKinesisFirehoseClient* (producer) | Amazon Kinesis Firehose client to use for all requests for this endpoint | | FirehoseClient +| *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 | | KinesisFirehose2Configuration | *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) | The operation to do in case the user don't want to send only a record. The value can be one of: sendBatchRecord, createDeliveryStream, deleteDeliveryStream, updateDestination | | KinesisFirehose2Operations @@ -88,13 +89,14 @@ with the following path and query parameters: |=== -=== Query Parameters (12 parameters): +=== Query Parameters (13 parameters): [width="100%",cols="2,5,^1,2",options="header"] |=== | Name | Description | Default | Type | *amazonKinesisFirehoseClient* (producer) | Amazon Kinesis Firehose client to use for all requests for this endpoint | | FirehoseClient +| *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) | The operation to do in case the user don't want to send only a record. The value can be one of: sendBatchRecord, createDeliveryStream, deleteDeliveryStream, updateDestination | | KinesisFirehose2Operations | *proxyHost* (producer) | To define a proxy host when instantiating the Kinesis Firehose client | | String diff --git a/components/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/firehose/KinesisFirehose2Component.java b/components/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/firehose/KinesisFirehose2Component.java index e47f0df..3a23555 100644 --- a/components/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/firehose/KinesisFirehose2Component.java +++ b/components/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/firehose/KinesisFirehose2Component.java @@ -48,7 +48,9 @@ public class KinesisFirehose2Component extends DefaultComponent { configuration.setStreamName(remaining); KinesisFirehose2Endpoint endpoint = new KinesisFirehose2Endpoint(uri, configuration, this); setProperties(endpoint, parameters); - checkAndSetRegistryClient(configuration); + if (endpoint.getConfiguration().isAutoDiscoverClient()) { + checkAndSetRegistryClient(configuration); + } if (configuration.getAmazonKinesisFirehoseClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) { throw new IllegalArgumentException("AmazonKinesisFirehoseClient or accessKey and secretKey must be specified"); } diff --git a/components/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/firehose/KinesisFirehose2Configuration.java b/components/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/firehose/KinesisFirehose2Configuration.java index 7ad41cd..c6ce2f1 100644 --- a/components/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/firehose/KinesisFirehose2Configuration.java +++ b/components/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/firehose/KinesisFirehose2Configuration.java @@ -49,6 +49,9 @@ public class KinesisFirehose2Configuration implements Cloneable { private KinesisFirehose2Operations operation; @UriParam(defaultValue = "false", description = "If we want to trust all certificates in case of overriding the endpoint") private boolean trustAllCertificates; + @UriParam(label = "common", defaultValue = "true", description = "Setting the autoDiscoverClient mechanism, if true, the component will " + + " look for a client instance in the registry automatically otherwise it will skip that checking") + private boolean autoDiscoverClient = true; public void setAmazonKinesisFirehoseClient(FirehoseClient client) { this.amazonKinesisFirehoseClient = client; @@ -129,6 +132,14 @@ public class KinesisFirehose2Configuration implements Cloneable { public void setTrustAllCertificates(boolean trustAllCertificates) { this.trustAllCertificates = trustAllCertificates; } + + public boolean isAutoDiscoverClient() { + return autoDiscoverClient; + } + + public void setAutoDiscoverClient(boolean autoDiscoverClient) { + this.autoDiscoverClient = autoDiscoverClient; + } // ************************************************* // diff --git a/components/camel-aws2-kinesis/src/test/java/org/apache/camel/component/aws2/firehose/KinesisFirehoseComponentConfigurationTest.java b/components/camel-aws2-kinesis/src/test/java/org/apache/camel/component/aws2/firehose/KinesisFirehoseComponentConfigurationTest.java index 5beddfc..2f56efa 100644 --- a/components/camel-aws2-kinesis/src/test/java/org/apache/camel/component/aws2/firehose/KinesisFirehoseComponentConfigurationTest.java +++ b/components/camel-aws2-kinesis/src/test/java/org/apache/camel/component/aws2/firehose/KinesisFirehoseComponentConfigurationTest.java @@ -78,4 +78,15 @@ public class KinesisFirehoseComponentConfigurationTest extends CamelTestSupport assertEquals("localhost", endpoint.getConfiguration().getProxyHost()); assertEquals(Integer.valueOf(9000), endpoint.getConfiguration().getProxyPort()); } + + @Test + public void createEndpointWithAutoDiscoverClientFalse() throws Exception { + KinesisFirehose2Component component = context.getComponent("aws2-kinesis-firehose", KinesisFirehose2Component.class); + KinesisFirehose2Endpoint endpoint = (KinesisFirehose2Endpoint)component.createEndpoint("aws2-kinesis-firehose://some_stream_name?accessKey=xxxxx&secretKey=yyyyy&autoDiscoverClient=false"); + + assertEquals("some_stream_name", endpoint.getConfiguration().getStreamName()); + assertEquals("xxxxx", endpoint.getConfiguration().getAccessKey()); + assertEquals("yyyyy", endpoint.getConfiguration().getSecretKey()); + assertEquals(false, endpoint.getConfiguration().isAutoDiscoverClient()); + } } diff --git a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2KinesisFirehoseComponentBuilderFactory.java b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2KinesisFirehoseComponentBuilderFactory.java index cc4f342..16eafb2 100644 --- a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2KinesisFirehoseComponentBuilderFactory.java +++ b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2KinesisFirehoseComponentBuilderFactory.java @@ -64,6 +64,21 @@ public interface Aws2KinesisFirehoseComponentBuilderFactory { 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 Aws2KinesisFirehoseComponentBuilder autoDiscoverClient( + boolean autoDiscoverClient) { + doSetProperty("autoDiscoverClient", autoDiscoverClient); + return this; + } + /** * Component configuration. * * The option is a: @@ -244,6 +259,7 @@ public interface Aws2KinesisFirehoseComponentBuilderFactory { Object value) { switch (name) { case "amazonKinesisFirehoseClient": getOrCreateConfiguration((KinesisFirehose2Component) component).setAmazonKinesisFirehoseClient((software.amazon.awssdk.services.firehose.FirehoseClient) value); return true; + case "autoDiscoverClient": getOrCreateConfiguration((KinesisFirehose2Component) component).setAutoDiscoverClient((boolean) value); return true; case "configuration": ((KinesisFirehose2Component) component).setConfiguration((org.apache.camel.component.aws2.firehose.KinesisFirehose2Configuration) value); return true; case "lazyStartProducer": ((KinesisFirehose2Component) component).setLazyStartProducer((boolean) value); return true; case "operation": getOrCreateConfiguration((KinesisFirehose2Component) component).setOperation((org.apache.camel.component.aws2.firehose.KinesisFirehose2Operations) value); return true; diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/KinesisFirehose2EndpointBuilderFactory.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/KinesisFirehose2EndpointBuilderFactory.java index a4d7d85..b06ace1 100644 --- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/KinesisFirehose2EndpointBuilderFactory.java +++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/KinesisFirehose2EndpointBuilderFactory.java @@ -70,6 +70,36 @@ public interface KinesisFirehose2EndpointBuilderFactory { 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 KinesisFirehose2EndpointBuilder 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 KinesisFirehose2EndpointBuilder 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