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 27fe3f0a176f5f38fe99c5e083ba0f0c5f4836a4 Author: Andrea Cosentino <[email protected]> AuthorDate: Fri Feb 28 16:22:20 2020 +0100 CAMEL-14568 - Fixed AWS MSK --- .../component/aws/msk/MSKComponentConfigurer.java | 7 ++-- .../apache/camel/component/aws/msk/aws-msk.json | 8 ++-- .../src/main/docs/aws-msk-component.adoc | 2 +- .../camel/component/aws/msk/MSKComponent.java | 48 ++-------------------- .../aws/msk/MSKComponentConfigurationTest.java | 16 ++++---- .../dsl/AwsMskComponentBuilderFactory.java | 34 +++++++-------- 6 files changed, 36 insertions(+), 79 deletions(-) diff --git a/components/camel-aws-msk/src/generated/java/org/apache/camel/component/aws/msk/MSKComponentConfigurer.java b/components/camel-aws-msk/src/generated/java/org/apache/camel/component/aws/msk/MSKComponentConfigurer.java index 08c06ad..dcd2387 100644 --- a/components/camel-aws-msk/src/generated/java/org/apache/camel/component/aws/msk/MSKComponentConfigurer.java +++ b/components/camel-aws-msk/src/generated/java/org/apache/camel/component/aws/msk/MSKComponentConfigurer.java @@ -23,7 +23,8 @@ public class MSKComponentConfigurer extends PropertyConfigurerSupport implements MSKComponent target = (MSKComponent) obj; switch (ignoreCase ? name.toLowerCase() : name) { case "accesskey": - case "accessKey": target.setAccessKey(property(camelContext, java.lang.String.class, value)); return true; + case "accessKey": getOrCreateConfiguration(target).setAccessKey(property(camelContext, java.lang.String.class, value)); return true; + case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.aws.msk.MSKConfiguration.class, value)); return true; case "lazystartproducer": case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true; case "mskclient": @@ -35,13 +36,11 @@ public class MSKComponentConfigurer extends PropertyConfigurerSupport implements case "proxyPort": getOrCreateConfiguration(target).setProxyPort(property(camelContext, java.lang.Integer.class, value)); return true; case "proxyprotocol": case "proxyProtocol": getOrCreateConfiguration(target).setProxyProtocol(property(camelContext, com.amazonaws.Protocol.class, value)); return true; - case "region": target.setRegion(property(camelContext, java.lang.String.class, value)); return true; case "region": getOrCreateConfiguration(target).setRegion(property(camelContext, java.lang.String.class, value)); return true; case "secretkey": - case "secretKey": target.setSecretKey(property(camelContext, java.lang.String.class, value)); return true; + case "secretKey": getOrCreateConfiguration(target).setSecretKey(property(camelContext, java.lang.String.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.aws.msk.MSKConfiguration.class, value)); return true; default: return false; } } diff --git a/components/camel-aws-msk/src/generated/resources/org/apache/camel/component/aws/msk/aws-msk.json b/components/camel-aws-msk/src/generated/resources/org/apache/camel/component/aws/msk/aws-msk.json index e6ee094..e0a4a33 100644 --- a/components/camel-aws-msk/src/generated/resources/org/apache/camel/component/aws/msk/aws-msk.json +++ b/components/camel-aws-msk/src/generated/resources/org/apache/camel/component/aws/msk/aws-msk.json @@ -19,7 +19,8 @@ "version": "3.2.0-SNAPSHOT" }, "componentProperties": { - "accessKey": { "kind": "property", "displayName": "Access Key", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "description": "Amazon AWS Access Key" }, + "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.msk.MSKConfiguration", "configurationField": "configuration", "description": "Amazon AWS Access Key" }, + "configuration": { "kind": "property", "displayName": "Configuration", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.aws.msk.MSKConfiguration", "deprecated": false, "secret": false, "description": "The 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 [...] "mskClient": { "kind": "property", "displayName": "Msk Client", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "com.amazonaws.services.kafka.AWSKafka", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws.msk.MSKConfiguration", "configurationField": "configuration", "description": "To use a existing configured AWS MSK as client" }, "operation": { "kind": "property", "displayName": "Operation", "group": "producer", "label": "producer", "required": true, "type": "object", "javaType": "org.apache.camel.component.aws.msk.MSKOperations", "enum": [ "listClusters", "createCluster", "deleteCluster", "describeCluster" ], "deprecated": false, "deprecationNote": "", "secret": false, "configurationClass": "org.apache.camel.component.aws.msk.MSKConfiguration", "configurationField": "configuration", "description": "The opera [...] @@ -27,9 +28,8 @@ "proxyPort": { "kind": "property", "displayName": "Proxy Port", "group": "producer", "label": "producer", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws.msk.MSKConfiguration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the MSK client" }, "proxyProtocol": { "kind": "property", "displayName": "Proxy Protocol", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "com.amazonaws.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws.msk.MSKConfiguration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the MSK client" }, "region": { "kind": "property", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws.msk.MSKConfiguration", "configurationField": "configuration", "description": "The region in which MSK client needs to work. When using this parameter, the configuration will expect the capitalized name of the region (for example AP_EAST [...] - "secretKey": { "kind": "property", "displayName": "Secret Key", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "description": "Amazon AWS Secret Key" }, - "basicPropertyBinding": { "kind": "property", "displayName": "Basic Property Binding", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities" }, - "configuration": { "kind": "property", "displayName": "Configuration", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.aws.msk.MSKConfiguration", "deprecated": false, "secret": false, "description": "The AWS MSK default configuration" } + "secretKey": { "kind": "property", "displayName": "Secret Key", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": true, "configurationClass": "org.apache.camel.component.aws.msk.MSKConfiguration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }, + "basicPropertyBinding": { "kind": "property", "displayName": "Basic Property Binding", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities" } }, "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.msk.MSKConfiguration", "configurationField": "configuration", "description": "Logical name" }, diff --git a/components/camel-aws-msk/src/main/docs/aws-msk-component.adoc b/components/camel-aws-msk/src/main/docs/aws-msk-component.adoc index cec670e..d647cc3 100644 --- a/components/camel-aws-msk/src/main/docs/aws-msk-component.adoc +++ b/components/camel-aws-msk/src/main/docs/aws-msk-component.adoc @@ -38,6 +38,7 @@ The AWS MSK component supports 11 options, which are listed below. |=== | Name | Description | Default | Type | *accessKey* (producer) | Amazon AWS Access Key | | String +| *configuration* (producer) | The component configuration | | MSKConfiguration | *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 [...] | *mskClient* (producer) | To use a existing configured AWS MSK as client | | AWSKafka | *operation* (producer) | *Required* The operation to perform. The value can be one of: listClusters, createCluster, deleteCluster, describeCluster | | MSKOperations @@ -47,7 +48,6 @@ The AWS MSK component supports 11 options, which are listed below. | *region* (producer) | The region in which MSK client needs to work. When using this parameter, the configuration will expect the capitalized name of the region (for example AP_EAST_1) You'll need to use the name Regions.EU_WEST_1.name() | | String | *secretKey* (producer) | Amazon AWS Secret Key | | String | *basicPropertyBinding* (advanced) | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean -| *configuration* (advanced) | The AWS MSK default configuration | | MSKConfiguration |=== // component options: END diff --git a/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/msk/MSKComponent.java b/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/msk/MSKComponent.java index a5b4285..09afbdc 100644 --- a/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/msk/MSKComponent.java +++ b/components/camel-aws-msk/src/main/java/org/apache/camel/component/aws/msk/MSKComponent.java @@ -32,14 +32,8 @@ import org.apache.camel.support.DefaultComponent; @Component("aws-msk") public class MSKComponent extends DefaultComponent { - @Metadata - private String accessKey; - @Metadata - private String secretKey; - @Metadata - private String region; - @Metadata(label = "advanced") - private MSKConfiguration configuration; + @Metadata + private MSKConfiguration configuration = new MSKConfiguration(); public MSKComponent() { this(null); @@ -55,9 +49,6 @@ public class MSKComponent extends DefaultComponent { protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { MSKConfiguration configuration = this.configuration != null ? this.configuration.copy() : new MSKConfiguration(); MSKEndpoint endpoint = new MSKEndpoint(uri, this, configuration); - endpoint.getConfiguration().setAccessKey(accessKey); - endpoint.getConfiguration().setSecretKey(secretKey); - endpoint.getConfiguration().setRegion(region); setProperties(endpoint, parameters); checkAndSetRegistryClient(configuration); if (configuration.getMskClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) { @@ -71,45 +62,12 @@ public class MSKComponent extends DefaultComponent { } /** - * The AWS MSK default configuration + * The component configuration */ public void setConfiguration(MSKConfiguration configuration) { this.configuration = configuration; } - public String getAccessKey() { - return accessKey; - } - - /** - * Amazon AWS Access Key - */ - public void setAccessKey(String accessKey) { - this.accessKey = accessKey; - } - - public String getSecretKey() { - return secretKey; - } - - /** - * Amazon AWS Secret Key - */ - public void setSecretKey(String secretKey) { - this.secretKey = secretKey; - } - - public String getRegion() { - return region; - } - - /** - * The region in which MSK client needs to work - */ - public void setRegion(String region) { - this.region = region; - } - private void checkAndSetRegistryClient(MSKConfiguration configuration) { Set<AWSKafka> clients = getCamelContext().getRegistry().findByType(AWSKafka.class); if (clients.size() == 1) { diff --git a/components/camel-aws-msk/src/test/java/org/apache/camel/component/aws/msk/MSKComponentConfigurationTest.java b/components/camel-aws-msk/src/test/java/org/apache/camel/component/aws/msk/MSKComponentConfigurationTest.java index 9f68f72..8d02369 100644 --- a/components/camel-aws-msk/src/test/java/org/apache/camel/component/aws/msk/MSKComponentConfigurationTest.java +++ b/components/camel-aws-msk/src/test/java/org/apache/camel/component/aws/msk/MSKComponentConfigurationTest.java @@ -26,8 +26,8 @@ public class MSKComponentConfigurationTest extends CamelTestSupport { @Test public void createEndpointWithComponentElements() throws Exception { MSKComponent component = context.getComponent("aws-msk", MSKComponent.class); - component.setAccessKey("XXX"); - component.setSecretKey("YYY"); + component.getConfiguration().setAccessKey("XXX"); + component.getConfiguration().setSecretKey("YYY"); MSKEndpoint endpoint = (MSKEndpoint)component.createEndpoint("aws-msk://label"); assertEquals("XXX", endpoint.getConfiguration().getAccessKey()); @@ -37,9 +37,9 @@ public class MSKComponentConfigurationTest extends CamelTestSupport { @Test public void createEndpointWithComponentAndEndpointElements() throws Exception { MSKComponent component = context.getComponent("aws-msk", MSKComponent.class); - component.setAccessKey("XXX"); - component.setSecretKey("YYY"); - component.setRegion(Regions.US_WEST_1.toString()); + component.getConfiguration().setAccessKey("XXX"); + component.getConfiguration().setSecretKey("YYY"); + component.getConfiguration().setRegion(Regions.US_WEST_1.toString()); MSKEndpoint endpoint = (MSKEndpoint)component.createEndpoint("aws-msk://label?accessKey=xxxxxx&secretKey=yyyyy®ion=US_EAST_1"); assertEquals("xxxxxx", endpoint.getConfiguration().getAccessKey()); @@ -50,9 +50,9 @@ public class MSKComponentConfigurationTest extends CamelTestSupport { @Test public void createEndpointWithComponentEndpointElementsAndProxy() throws Exception { MSKComponent component = context.getComponent("aws-msk", MSKComponent.class); - component.setAccessKey("XXX"); - component.setSecretKey("YYY"); - component.setRegion(Regions.US_WEST_1.toString()); + component.getConfiguration().setAccessKey("XXX"); + component.getConfiguration().setSecretKey("YYY"); + component.getConfiguration().setRegion(Regions.US_WEST_1.toString()); MSKEndpoint endpoint = (MSKEndpoint)component.createEndpoint("aws-msk://label?accessKey=xxxxxx&secretKey=yyyyy®ion=US_EAST_1&proxyHost=localhost&proxyPort=9000&proxyProtocol=HTTP"); assertEquals("xxxxxx", endpoint.getConfiguration().getAccessKey()); diff --git a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsMskComponentBuilderFactory.java b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsMskComponentBuilderFactory.java index d849bab..b6f45ce 100644 --- a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsMskComponentBuilderFactory.java +++ b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsMskComponentBuilderFactory.java @@ -58,6 +58,20 @@ public interface AwsMskComponentBuilderFactory { return this; } /** + * The component configuration. + * + * The option is a: + * <code>org.apache.camel.component.aws.msk.MSKConfiguration</code> + * type. + * + * Group: producer + */ + default AwsMskComponentBuilder configuration( + org.apache.camel.component.aws.msk.MSKConfiguration configuration) { + doSetProperty("configuration", configuration); + 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 @@ -178,20 +192,6 @@ public interface AwsMskComponentBuilderFactory { doSetProperty("basicPropertyBinding", basicPropertyBinding); return this; } - /** - * The AWS MSK default configuration. - * - * The option is a: - * <code>org.apache.camel.component.aws.msk.MSKConfiguration</code> - * type. - * - * Group: advanced - */ - default AwsMskComponentBuilder configuration( - org.apache.camel.component.aws.msk.MSKConfiguration configuration) { - doSetProperty("configuration", configuration); - return this; - } } class AwsMskComponentBuilderImpl @@ -216,7 +216,8 @@ public interface AwsMskComponentBuilderFactory { String name, Object value) { switch (name) { - case "accessKey": ((MSKComponent) component).setAccessKey((java.lang.String) value); return true; + case "accessKey": getOrCreateConfiguration((MSKComponent) component).setAccessKey((java.lang.String) value); return true; + case "configuration": ((MSKComponent) component).setConfiguration((org.apache.camel.component.aws.msk.MSKConfiguration) value); return true; case "lazyStartProducer": ((MSKComponent) component).setLazyStartProducer((boolean) value); return true; case "mskClient": getOrCreateConfiguration((MSKComponent) component).setMskClient((com.amazonaws.services.kafka.AWSKafka) value); return true; case "operation": getOrCreateConfiguration((MSKComponent) component).setOperation((org.apache.camel.component.aws.msk.MSKOperations) value); return true; @@ -224,9 +225,8 @@ public interface AwsMskComponentBuilderFactory { case "proxyPort": getOrCreateConfiguration((MSKComponent) component).setProxyPort((java.lang.Integer) value); return true; case "proxyProtocol": getOrCreateConfiguration((MSKComponent) component).setProxyProtocol((com.amazonaws.Protocol) value); return true; case "region": getOrCreateConfiguration((MSKComponent) component).setRegion((java.lang.String) value); return true; - case "secretKey": ((MSKComponent) component).setSecretKey((java.lang.String) value); return true; + case "secretKey": getOrCreateConfiguration((MSKComponent) component).setSecretKey((java.lang.String) value); return true; case "basicPropertyBinding": ((MSKComponent) component).setBasicPropertyBinding((boolean) value); return true; - case "configuration": ((MSKComponent) component).setConfiguration((org.apache.camel.component.aws.msk.MSKConfiguration) value); return true; default: return false; } }
