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/11/17 14:22:59 UTC

[camel] branch master updated (7679e8b -> 2c1f78e)

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 7679e8b  CAMEL-15836 - Camel-AWS2-MSK: enable autowire on the MSK Client, Added a note to migration guide
     new 0f0f3a3  CAMEL-15836 - Camel-AWS2-SES: enable autowire on the SES Client
     new b4eabfe  CAMEL-15836 - Camel-AWS2-SES: enable autowire on the SES Client, regen configurers and component
     new 657d4c6  CAMEL-15836 - Camel-AWS2-SES: enable autowire on the SES Client, fixed tests
     new 933c06c  CAMEL-15836 - Camel-AWS2-SES: enable autowire on the SES Client, fixed tests
     new 6780428  CAMEL-15836 - Camel-AWS2-SES: enable autowire on the SES Client, fixed tests
     new adb42dc  CAMEL-15836 - Camel-AWS2-SES: enable autowire on the SES Client, regen catalog
     new 2c1f78e  CAMEL-15836 - Camel-AWS2-SES: enable autowire on the SES Client, added note to migration guide

The 7 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:
 .../apache/camel/catalog/components/aws2-ses.json  |  6 ++--
 .../camel/catalog/docs/aws2-ses-component.adoc     | 10 +++----
 .../aws2/ses/Ses2ComponentConfigurer.java          | 11 ++++----
 .../component/aws2/ses/Ses2EndpointConfigurer.java | 11 ++++----
 .../component/aws2/ses/Ses2EndpointUriFactory.java |  3 +-
 .../apache/camel/component/aws2/ses/aws2-ses.json  |  6 ++--
 .../src/main/docs/aws2-ses-component.adoc          | 10 +++----
 .../camel/component/aws2/ses/Ses2Component.java    | 21 --------------
 .../component/aws2/ses/Ses2Configuration.java      | 15 +---------
 .../aws2/ses/SESComponentClientRegistryTest.java   | 32 +++-------------------
 .../dsl/Aws2SesComponentBuilderFactory.java        | 16 -----------
 .../endpoint/dsl/Ses2EndpointBuilderFactory.java   | 29 --------------------
 .../modules/ROOT/pages/aws2-ses-component.adoc     | 10 +++----
 .../ROOT/pages/camel-3x-upgrade-guide-3_7.adoc     |  5 ++++
 14 files changed, 37 insertions(+), 148 deletions(-)


[camel] 06/07: CAMEL-15836 - Camel-AWS2-SES: enable autowire on the SES Client, regen catalog

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 adb42dca78edf875bf9ee2709e01e1223fa72700
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Nov 17 15:21:05 2020 +0100

    CAMEL-15836 - Camel-AWS2-SES: enable autowire on the SES Client, regen catalog
---
 .../resources/org/apache/camel/catalog/components/aws2-ses.json     | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-ses.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-ses.json
index b86f67c..d8fd9b2 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-ses.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-ses.json
@@ -22,8 +22,7 @@
     "lenientProperties": false
   },
   "componentProperties": {
-    "amazonSESClient": { "kind": "property", "displayName": "Amazon SESClient", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.ses.SesClient", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": "configuration", "description": "To use the AmazonSimpleEmailService as the client" },
-    "autoDiscoverClient": { "kind": "property", "displayName": "Auto Discover Client", "group": "common", "label": "common", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": "configuration", "description": "Setting the autoDiscoverClient mechanism, if true, the component will look for a client inst [...]
+    "amazonSESClient": { "kind": "property", "displayName": "Amazon SESClient", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.ses.SesClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": "configuration", "description": "To use the AmazonSimpleEmailService as the client" },
     "configuration": { "kind": "property", "displayName": "Configuration", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.aws2.ses.Ses2Configuration", "deprecated": false, "autowired": 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, "autowired": 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 star [...]
     "proxyHost": { "kind": "property", "displayName": "Proxy Host", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the SES client" },
@@ -41,8 +40,7 @@
   },
   "properties": {
     "from": { "kind": "path", "displayName": "From", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": "configuration", "description": "The sender's email address." },
-    "amazonSESClient": { "kind": "parameter", "displayName": "Amazon SESClient", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.ses.SesClient", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": "configuration", "description": "To use the AmazonSimpleEmailService as the client" },
-    "autoDiscoverClient": { "kind": "parameter", "displayName": "Auto Discover Client", "group": "common", "label": "common", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": "configuration", "description": "Setting the autoDiscoverClient mechanism, if true, the component will look for a client ins [...]
+    "amazonSESClient": { "kind": "parameter", "displayName": "Amazon SESClient", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.ses.SesClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": "configuration", "description": "To use the AmazonSimpleEmailService as the client" },
     "lazyStartProducer": { "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": 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 sta [...]
     "proxyHost": { "kind": "parameter", "displayName": "Proxy Host", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the SES client" },
     "proxyPort": { "kind": "parameter", "displayName": "Proxy Port", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the SES client" },


[camel] 07/07: CAMEL-15836 - Camel-AWS2-SES: enable autowire on the SES Client, added note to migration guide

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 2c1f78ec9eeee7770e9b937fa4c4a40a8d7b68dc
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Nov 17 15:22:15 2020 +0100

    CAMEL-15836 - Camel-AWS2-SES: enable autowire on the SES Client, added note to migration guide
---
 docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_7.adoc | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_7.adoc b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_7.adoc
index ad785d8..a1768c4 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_7.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_7.adoc
@@ -229,4 +229,9 @@ In this context, it wasn't having any sense to maintain the autodiscoverClient o
 The camel-aws2-msk has now support for autowiring the mskClient option with KafkaClient instance coming from the registry.
 In this context, it wasn't having any sense to maintain the autodiscoverClient option, which has been now removed.
 
+=== Camel-AWS2-SES Autowire support
+
+The camel-aws2-ses has now support for autowiring the amazonSESClient option with SesClient instance coming from the registry.
+In this context, it wasn't having any sense to maintain the autodiscoverClient option, which has been now removed.
+
 


[camel] 01/07: CAMEL-15836 - Camel-AWS2-SES: enable autowire on the SES Client

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 0f0f3a39fafb7d176d685101f2a674f6ea327152
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Nov 17 13:56:32 2020 +0100

    CAMEL-15836 - Camel-AWS2-SES: enable autowire on the SES Client
---
 .../apache/camel/component/aws2/ses/Ses2Component.java | 18 ------------------
 .../camel/component/aws2/ses/Ses2Configuration.java    | 15 +--------------
 2 files changed, 1 insertion(+), 32 deletions(-)

diff --git a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
index 0175553..9c31332 100644
--- a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
+++ b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
@@ -60,9 +60,6 @@ public class Ses2Component extends DefaultComponent {
         configuration.setFrom(remaining);
         Ses2Endpoint endpoint = new Ses2Endpoint(uri, this, configuration);
         setProperties(endpoint, parameters);
-        if (endpoint.getConfiguration().isAutoDiscoverClient()) {
-            checkAndSetRegistryClient(configuration, endpoint);
-        }
         if (configuration.getAmazonSESClient() == null
                 && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
             throw new IllegalArgumentException("AmazonSESClient or accessKey and secretKey must be specified");
@@ -81,19 +78,4 @@ public class Ses2Component extends DefaultComponent {
     public void setConfiguration(Ses2Configuration configuration) {
         this.configuration = configuration;
     }
-
-    private void checkAndSetRegistryClient(Ses2Configuration configuration, Ses2Endpoint endpoint) {
-        if (ObjectHelper.isEmpty(endpoint.getConfiguration().getAmazonSESClient())) {
-            LOG.debug("Looking for an SesClient instance in the registry");
-            Set<SesClient> clients = getCamelContext().getRegistry().findByType(SesClient.class);
-            if (clients.size() == 1) {
-                LOG.debug("Found exactly one SesClient instance in the registry");
-                configuration.setAmazonSESClient(clients.stream().findFirst().get());
-            } else {
-                LOG.debug("No SesClient instance in the registry");
-            }
-        } else {
-            LOG.debug("SesClient instance is already set at endpoint level: skipping the check in the registry");
-        }
-    }
 }
diff --git a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Configuration.java b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Configuration.java
index 61d0e42..ced6e85 100644
--- a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Configuration.java
+++ b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Configuration.java
@@ -34,6 +34,7 @@ public class Ses2Configuration implements Cloneable {
     @Metadata(required = true)
     private String from;
     @UriParam
+    @Metadata(autowired = true)
     private SesClient amazonSESClient;
     @UriParam(label = "security", secret = true)
     private String accessKey;
@@ -57,8 +58,6 @@ public class Ses2Configuration implements Cloneable {
     private String region;
     @UriParam(defaultValue = "false")
     private boolean trustAllCertificates;
-    @UriParam(label = "common", defaultValue = "true")
-    private boolean autoDiscoverClient = true;
 
     public String getAccessKey() {
         return accessKey;
@@ -216,18 +215,6 @@ public class Ses2Configuration implements Cloneable {
         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;
-    }
-
     // *************************************************
     //
     // *************************************************


[camel] 03/07: CAMEL-15836 - Camel-AWS2-SES: enable autowire on the SES Client, fixed tests

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 657d4c6e3e50c7b0ad7296572928c0162a869c38
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Nov 17 15:09:16 2020 +0100

    CAMEL-15836 - Camel-AWS2-SES: enable autowire on the SES Client, fixed tests
---
 .../aws2/ses/SESComponentClientRegistryTest.java   | 25 +---------------------
 1 file changed, 1 insertion(+), 24 deletions(-)

diff --git a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java
index 637446a..5b9fb37f 100644
--- a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java
+++ b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java
@@ -20,7 +20,6 @@ import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNotSame;
 import static org.junit.jupiter.api.Assertions.assertSame;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 
@@ -39,29 +38,7 @@ public class SESComponentClientRegistryTest extends CamelTestSupport {
     }
 
     @Test
-    public void createEndpointWithMinimalSESClientMisconfiguration() throws Exception {
-
-        Ses2Component component = new Ses2Component(context);
-        assertThrows(IllegalArgumentException.class, () -> {
-            component.createEndpoint("aws2-ses://from@example.com");
-        });
-        component.close();
-    }
-
-    @Test
-    public void createEndpointWithAutoDiscoverClientFalse() throws Exception {
-
-        AmazonSESClientMock awsSESClient = new AmazonSESClientMock();
-        context.getRegistry().bind("awsSesClient", awsSESClient);
-        Ses2Component component = context.getComponent("aws2-ses", Ses2Component.class);
-        Ses2Endpoint endpoint = (Ses2Endpoint) component
-                .createEndpoint("aws2-ses://from@example.com?accessKey=xxx&secretKey=yyy&autoDiscoverClient=false");
-
-        assertNotSame(awsSESClient, endpoint.getConfiguration().getAmazonSESClient());
-    }
-
-    @Test
-    public void createEndpointWithAutoDiscoverClientTrue() throws Exception {
+    public void createEndpointWithAutowire() throws Exception {
 
         AmazonSESClientMock awsSESClient = new AmazonSESClientMock();
         context.getRegistry().bind("awsSesClient", awsSESClient);


[camel] 02/07: CAMEL-15836 - Camel-AWS2-SES: enable autowire on the SES Client, regen configurers and component

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 b4eabfe6dc51efa68d3b9c539f2bbb7499c1c129
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Nov 17 15:05:33 2020 +0100

    CAMEL-15836 - Camel-AWS2-SES: enable autowire on the SES Client, regen configurers and component
---
 .../camel/catalog/docs/aws2-ses-component.adoc     | 10 +++-----
 .../aws2/ses/Ses2ComponentConfigurer.java          | 11 ++++----
 .../component/aws2/ses/Ses2EndpointConfigurer.java | 11 ++++----
 .../component/aws2/ses/Ses2EndpointUriFactory.java |  3 +--
 .../apache/camel/component/aws2/ses/aws2-ses.json  |  6 ++---
 .../src/main/docs/aws2-ses-component.adoc          | 10 +++-----
 .../camel/component/aws2/ses/Ses2Component.java    |  3 ---
 .../dsl/Aws2SesComponentBuilderFactory.java        | 16 ------------
 .../endpoint/dsl/Ses2EndpointBuilderFactory.java   | 29 ----------------------
 .../modules/ROOT/pages/aws2-ses-component.adoc     | 10 +++-----
 10 files changed, 25 insertions(+), 84 deletions(-)

diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-ses-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-ses-component.adoc
index 000b992..b576394 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-ses-component.adoc
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-ses-component.adoc
@@ -37,15 +37,14 @@ You can append query options to the URI in the following format,
 
 
 // component options: START
-The AWS 2 Simple Email Service (SES) component supports 16 options, which are listed below.
+The AWS 2 Simple Email Service (SES) component supports 15 options, which are listed below.
 
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *amazonSESClient* (producer) | To use the AmazonSimpleEmailService as the client |  | SesClient
-| *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
+| *amazonSESClient* (producer) | *Autowired* To use the AmazonSimpleEmailService as the client |  | SesClient
 | *configuration* (producer) | component configuration |  | Ses2Configuration
 | *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 [...]
 | *proxyHost* (producer) | To define a proxy host when instantiating the SES client |  | String
@@ -85,14 +84,13 @@ with the following path and query parameters:
 |===
 
 
-=== Query Parameters (15 parameters):
+=== Query Parameters (14 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *amazonSESClient* (producer) | To use the AmazonSimpleEmailService as the client |  | SesClient
-| *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
+| *amazonSESClient* (producer) | *Autowired* To use the AmazonSimpleEmailService as the client |  | SesClient
 | *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 [...]
 | *proxyHost* (producer) | To define a proxy host when instantiating the SES client |  | String
 | *proxyPort* (producer) | To define a proxy port when instantiating the SES client |  | Integer
diff --git a/components/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2ComponentConfigurer.java b/components/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2ComponentConfigurer.java
index bd33f13..1c665f5 100644
--- a/components/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2ComponentConfigurer.java
+++ b/components/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2ComponentConfigurer.java
@@ -32,8 +32,6 @@ public class Ses2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "accessKey": getOrCreateConfiguration(target).setAccessKey(property(camelContext, java.lang.String.class, value)); return true;
         case "amazonsesclient":
         case "amazonSESClient": getOrCreateConfiguration(target).setAmazonSESClient(property(camelContext, software.amazon.awssdk.services.ses.SesClient.class, value)); return true;
-        case "autodiscoverclient":
-        case "autoDiscoverClient": getOrCreateConfiguration(target).setAutoDiscoverClient(property(camelContext, boolean.class, value)); return true;
         case "autowiredenabled":
         case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true;
         case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.aws2.ses.Ses2Configuration.class, value)); return true;
@@ -61,14 +59,17 @@ public class Ses2ComponentConfigurer extends PropertyConfigurerSupport implement
     }
 
     @Override
+    public String[] getAutowiredNames() {
+        return new String[]{"amazonSESClient"};
+    }
+
+    @Override
     public Class<?> getOptionType(String name, boolean ignoreCase) {
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "accesskey":
         case "accessKey": return java.lang.String.class;
         case "amazonsesclient":
         case "amazonSESClient": return software.amazon.awssdk.services.ses.SesClient.class;
-        case "autodiscoverclient":
-        case "autoDiscoverClient": return boolean.class;
         case "autowiredenabled":
         case "autowiredEnabled": return boolean.class;
         case "configuration": return org.apache.camel.component.aws2.ses.Ses2Configuration.class;
@@ -103,8 +104,6 @@ public class Ses2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "accessKey": return getOrCreateConfiguration(target).getAccessKey();
         case "amazonsesclient":
         case "amazonSESClient": return getOrCreateConfiguration(target).getAmazonSESClient();
-        case "autodiscoverclient":
-        case "autoDiscoverClient": return getOrCreateConfiguration(target).isAutoDiscoverClient();
         case "autowiredenabled":
         case "autowiredEnabled": return target.isAutowiredEnabled();
         case "configuration": return target.getConfiguration();
diff --git a/components/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2EndpointConfigurer.java b/components/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2EndpointConfigurer.java
index 8eed84b..13a6c27 100644
--- a/components/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2EndpointConfigurer.java
+++ b/components/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2EndpointConfigurer.java
@@ -25,8 +25,6 @@ public class Ses2EndpointConfigurer extends PropertyConfigurerSupport implements
         case "accessKey": target.getConfiguration().setAccessKey(property(camelContext, java.lang.String.class, value)); return true;
         case "amazonsesclient":
         case "amazonSESClient": target.getConfiguration().setAmazonSESClient(property(camelContext, software.amazon.awssdk.services.ses.SesClient.class, value)); return true;
-        case "autodiscoverclient":
-        case "autoDiscoverClient": target.getConfiguration().setAutoDiscoverClient(property(camelContext, boolean.class, value)); return true;
         case "lazystartproducer":
         case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
         case "proxyhost":
@@ -52,14 +50,17 @@ public class Ses2EndpointConfigurer extends PropertyConfigurerSupport implements
     }
 
     @Override
+    public String[] getAutowiredNames() {
+        return new String[]{"amazonSESClient"};
+    }
+
+    @Override
     public Class<?> getOptionType(String name, boolean ignoreCase) {
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "accesskey":
         case "accessKey": return java.lang.String.class;
         case "amazonsesclient":
         case "amazonSESClient": return software.amazon.awssdk.services.ses.SesClient.class;
-        case "autodiscoverclient":
-        case "autoDiscoverClient": return boolean.class;
         case "lazystartproducer":
         case "lazyStartProducer": return boolean.class;
         case "proxyhost":
@@ -92,8 +93,6 @@ public class Ses2EndpointConfigurer extends PropertyConfigurerSupport implements
         case "accessKey": return target.getConfiguration().getAccessKey();
         case "amazonsesclient":
         case "amazonSESClient": return target.getConfiguration().getAmazonSESClient();
-        case "autodiscoverclient":
-        case "autoDiscoverClient": return target.getConfiguration().isAutoDiscoverClient();
         case "lazystartproducer":
         case "lazyStartProducer": return target.isLazyStartProducer();
         case "proxyhost":
diff --git a/components/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2EndpointUriFactory.java b/components/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2EndpointUriFactory.java
index d2b2e0c..ab8d92d 100644
--- a/components/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2EndpointUriFactory.java
+++ b/components/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2EndpointUriFactory.java
@@ -20,8 +20,7 @@ public class Ses2EndpointUriFactory extends org.apache.camel.support.component.E
     private static final Set<String> PROPERTY_NAMES;
     private static final Set<String> SECRET_PROPERTY_NAMES;
     static {
-        Set<String> props = new HashSet<>(16);
-        props.add("autoDiscoverClient");
+        Set<String> props = new HashSet<>(15);
         props.add("proxyProtocol");
         props.add("returnPath");
         props.add("secretKey");
diff --git a/components/camel-aws2-ses/src/generated/resources/org/apache/camel/component/aws2/ses/aws2-ses.json b/components/camel-aws2-ses/src/generated/resources/org/apache/camel/component/aws2/ses/aws2-ses.json
index b86f67c..d8fd9b2 100644
--- a/components/camel-aws2-ses/src/generated/resources/org/apache/camel/component/aws2/ses/aws2-ses.json
+++ b/components/camel-aws2-ses/src/generated/resources/org/apache/camel/component/aws2/ses/aws2-ses.json
@@ -22,8 +22,7 @@
     "lenientProperties": false
   },
   "componentProperties": {
-    "amazonSESClient": { "kind": "property", "displayName": "Amazon SESClient", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.ses.SesClient", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": "configuration", "description": "To use the AmazonSimpleEmailService as the client" },
-    "autoDiscoverClient": { "kind": "property", "displayName": "Auto Discover Client", "group": "common", "label": "common", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": "configuration", "description": "Setting the autoDiscoverClient mechanism, if true, the component will look for a client inst [...]
+    "amazonSESClient": { "kind": "property", "displayName": "Amazon SESClient", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.ses.SesClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": "configuration", "description": "To use the AmazonSimpleEmailService as the client" },
     "configuration": { "kind": "property", "displayName": "Configuration", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.aws2.ses.Ses2Configuration", "deprecated": false, "autowired": 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, "autowired": 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 star [...]
     "proxyHost": { "kind": "property", "displayName": "Proxy Host", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the SES client" },
@@ -41,8 +40,7 @@
   },
   "properties": {
     "from": { "kind": "path", "displayName": "From", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": "configuration", "description": "The sender's email address." },
-    "amazonSESClient": { "kind": "parameter", "displayName": "Amazon SESClient", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.ses.SesClient", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": "configuration", "description": "To use the AmazonSimpleEmailService as the client" },
-    "autoDiscoverClient": { "kind": "parameter", "displayName": "Auto Discover Client", "group": "common", "label": "common", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": "configuration", "description": "Setting the autoDiscoverClient mechanism, if true, the component will look for a client ins [...]
+    "amazonSESClient": { "kind": "parameter", "displayName": "Amazon SESClient", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.ses.SesClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": "configuration", "description": "To use the AmazonSimpleEmailService as the client" },
     "lazyStartProducer": { "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": 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 sta [...]
     "proxyHost": { "kind": "parameter", "displayName": "Proxy Host", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the SES client" },
     "proxyPort": { "kind": "parameter", "displayName": "Proxy Port", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ses.Ses2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the SES client" },
diff --git a/components/camel-aws2-ses/src/main/docs/aws2-ses-component.adoc b/components/camel-aws2-ses/src/main/docs/aws2-ses-component.adoc
index 000b992..b576394 100644
--- a/components/camel-aws2-ses/src/main/docs/aws2-ses-component.adoc
+++ b/components/camel-aws2-ses/src/main/docs/aws2-ses-component.adoc
@@ -37,15 +37,14 @@ You can append query options to the URI in the following format,
 
 
 // component options: START
-The AWS 2 Simple Email Service (SES) component supports 16 options, which are listed below.
+The AWS 2 Simple Email Service (SES) component supports 15 options, which are listed below.
 
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *amazonSESClient* (producer) | To use the AmazonSimpleEmailService as the client |  | SesClient
-| *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
+| *amazonSESClient* (producer) | *Autowired* To use the AmazonSimpleEmailService as the client |  | SesClient
 | *configuration* (producer) | component configuration |  | Ses2Configuration
 | *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 [...]
 | *proxyHost* (producer) | To define a proxy host when instantiating the SES client |  | String
@@ -85,14 +84,13 @@ with the following path and query parameters:
 |===
 
 
-=== Query Parameters (15 parameters):
+=== Query Parameters (14 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *amazonSESClient* (producer) | To use the AmazonSimpleEmailService as the client |  | SesClient
-| *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
+| *amazonSESClient* (producer) | *Autowired* To use the AmazonSimpleEmailService as the client |  | SesClient
 | *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 [...]
 | *proxyHost* (producer) | To define a proxy host when instantiating the SES client |  | String
 | *proxyPort* (producer) | To define a proxy port when instantiating the SES client |  | Integer
diff --git a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
index 9c31332..a6fcc48 100644
--- a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
+++ b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
@@ -17,17 +17,14 @@
 package org.apache.camel.component.aws2.ses;
 
 import java.util.Map;
-import java.util.Set;
 
 import org.apache.camel.CamelContext;
 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.ses.SesClient;
 
 /**
  * For working with Amazon ECS SDK v2.
diff --git a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2SesComponentBuilderFactory.java b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2SesComponentBuilderFactory.java
index 63e1fff..5cb0e29 100644
--- a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2SesComponentBuilderFactory.java
+++ b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2SesComponentBuilderFactory.java
@@ -60,21 +60,6 @@ public interface Aws2SesComponentBuilderFactory {
             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 Aws2SesComponentBuilder autoDiscoverClient(
-                boolean autoDiscoverClient) {
-            doSetProperty("autoDiscoverClient", autoDiscoverClient);
-            return this;
-        }
-        /**
          * component configuration.
          * 
          * The option is a:
@@ -287,7 +272,6 @@ public interface Aws2SesComponentBuilderFactory {
                 Object value) {
             switch (name) {
             case "amazonSESClient": getOrCreateConfiguration((Ses2Component) component).setAmazonSESClient((software.amazon.awssdk.services.ses.SesClient) value); return true;
-            case "autoDiscoverClient": getOrCreateConfiguration((Ses2Component) component).setAutoDiscoverClient((boolean) value); return true;
             case "configuration": ((Ses2Component) component).setConfiguration((org.apache.camel.component.aws2.ses.Ses2Configuration) value); return true;
             case "lazyStartProducer": ((Ses2Component) component).setLazyStartProducer((boolean) value); return true;
             case "proxyHost": getOrCreateConfiguration((Ses2Component) component).setProxyHost((java.lang.String) value); return true;
diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Ses2EndpointBuilderFactory.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Ses2EndpointBuilderFactory.java
index e640ec8..621a0e7 100644
--- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Ses2EndpointBuilderFactory.java
+++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Ses2EndpointBuilderFactory.java
@@ -63,35 +63,6 @@ public interface Ses2EndpointBuilderFactory {
             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 Ses2EndpointBuilder 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 Ses2EndpointBuilder 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
diff --git a/docs/components/modules/ROOT/pages/aws2-ses-component.adoc b/docs/components/modules/ROOT/pages/aws2-ses-component.adoc
index 8371e92..0597f45 100644
--- a/docs/components/modules/ROOT/pages/aws2-ses-component.adoc
+++ b/docs/components/modules/ROOT/pages/aws2-ses-component.adoc
@@ -39,15 +39,14 @@ You can append query options to the URI in the following format,
 
 
 // component options: START
-The AWS 2 Simple Email Service (SES) component supports 16 options, which are listed below.
+The AWS 2 Simple Email Service (SES) component supports 15 options, which are listed below.
 
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *amazonSESClient* (producer) | To use the AmazonSimpleEmailService as the client |  | SesClient
-| *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
+| *amazonSESClient* (producer) | *Autowired* To use the AmazonSimpleEmailService as the client |  | SesClient
 | *configuration* (producer) | component configuration |  | Ses2Configuration
 | *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 [...]
 | *proxyHost* (producer) | To define a proxy host when instantiating the SES client |  | String
@@ -87,14 +86,13 @@ with the following path and query parameters:
 |===
 
 
-=== Query Parameters (15 parameters):
+=== Query Parameters (14 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *amazonSESClient* (producer) | To use the AmazonSimpleEmailService as the client |  | SesClient
-| *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
+| *amazonSESClient* (producer) | *Autowired* To use the AmazonSimpleEmailService as the client |  | SesClient
 | *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 [...]
 | *proxyHost* (producer) | To define a proxy host when instantiating the SES client |  | String
 | *proxyPort* (producer) | To define a proxy port when instantiating the SES client |  | Integer


[camel] 05/07: CAMEL-15836 - Camel-AWS2-SES: enable autowire on the SES Client, fixed tests

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 6780428dba4aef6f80644c4e0318519f4ac279a3
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Nov 17 15:19:48 2020 +0100

    CAMEL-15836 - Camel-AWS2-SES: enable autowire on the SES Client, fixed tests
---
 .../apache/camel/component/aws2/ses/Ses2Component.java | 18 ------------------
 .../aws2/ses/SESComponentClientRegistryTest.java       |  5 +++--
 2 files changed, 3 insertions(+), 20 deletions(-)

diff --git a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
index e7ce05b..a6fcc48 100644
--- a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
+++ b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
@@ -17,17 +17,14 @@
 package org.apache.camel.component.aws2.ses;
 
 import java.util.Map;
-import java.util.Set;
 
 import org.apache.camel.CamelContext;
 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.ses.SesClient;
 
 /**
  * For working with Amazon ECS SDK v2.
@@ -78,19 +75,4 @@ public class Ses2Component extends DefaultComponent {
     public void setConfiguration(Ses2Configuration configuration) {
         this.configuration = configuration;
     }
-
-    private void checkAndSetRegistryClient(Ses2Configuration configuration, Ses2Endpoint endpoint) {
-        if (ObjectHelper.isEmpty(endpoint.getConfiguration().getAmazonSESClient())) {
-            LOG.debug("Looking for an SesClient instance in the registry");
-            Set<SesClient> clients = getCamelContext().getRegistry().findByType(SesClient.class);
-            if (clients.size() == 1) {
-                LOG.debug("Found exactly one SesClient instance in the registry");
-                configuration.setAmazonSESClient(clients.stream().findFirst().get());
-            } else {
-                LOG.debug("No SesClient instance in the registry");
-            }
-        } else {
-            LOG.debug("SesClient instance is already set at endpoint level: skipping the check in the registry");
-        }
-    }
 }
diff --git a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java
index 0e64724..80e1141 100644
--- a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java
+++ b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java
@@ -29,8 +29,9 @@ public class SESComponentClientRegistryTest extends CamelTestSupport {
 
         AmazonSESClientMock awsSESClient = new AmazonSESClientMock();
         context.getRegistry().bind("awsSesClient", awsSESClient);
-        Ses2Component component = new Ses2Component(context);
-        Ses2Endpoint endpoint = (Ses2Endpoint) component.createEndpoint("aws2-ses://from@example.com?accessKey=xxx&secretKey=yyy");
+        Ses2Component component = context.getComponent("aws2-ses", Ses2Component.class);
+        Ses2Endpoint endpoint
+                = (Ses2Endpoint) component.createEndpoint("aws2-ses://from@example.com");
 
         assertNotNull(endpoint.getConfiguration().getAmazonSESClient());
     }


[camel] 04/07: CAMEL-15836 - Camel-AWS2-SES: enable autowire on the SES Client, fixed tests

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 933c06c80013e564d78eca7cffa922b75c39cbfe
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Nov 17 15:17:34 2020 +0100

    CAMEL-15836 - Camel-AWS2-SES: enable autowire on the SES Client, fixed tests
---
 .../apache/camel/component/aws2/ses/Ses2Component.java | 18 ++++++++++++++++++
 .../aws2/ses/SESComponentClientRegistryTest.java       |  4 +---
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
index a6fcc48..e7ce05b 100644
--- a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
+++ b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
@@ -17,14 +17,17 @@
 package org.apache.camel.component.aws2.ses;
 
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.camel.CamelContext;
 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.ses.SesClient;
 
 /**
  * For working with Amazon ECS SDK v2.
@@ -75,4 +78,19 @@ public class Ses2Component extends DefaultComponent {
     public void setConfiguration(Ses2Configuration configuration) {
         this.configuration = configuration;
     }
+
+    private void checkAndSetRegistryClient(Ses2Configuration configuration, Ses2Endpoint endpoint) {
+        if (ObjectHelper.isEmpty(endpoint.getConfiguration().getAmazonSESClient())) {
+            LOG.debug("Looking for an SesClient instance in the registry");
+            Set<SesClient> clients = getCamelContext().getRegistry().findByType(SesClient.class);
+            if (clients.size() == 1) {
+                LOG.debug("Found exactly one SesClient instance in the registry");
+                configuration.setAmazonSESClient(clients.stream().findFirst().get());
+            } else {
+                LOG.debug("No SesClient instance in the registry");
+            }
+        } else {
+            LOG.debug("SesClient instance is already set at endpoint level: skipping the check in the registry");
+        }
+    }
 }
diff --git a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java
index 5b9fb37f..0e64724 100644
--- a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java
+++ b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java
@@ -21,7 +21,6 @@ import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertSame;
-import static org.junit.jupiter.api.Assertions.assertThrows;
 
 public class SESComponentClientRegistryTest extends CamelTestSupport {
 
@@ -31,10 +30,9 @@ public class SESComponentClientRegistryTest extends CamelTestSupport {
         AmazonSESClientMock awsSESClient = new AmazonSESClientMock();
         context.getRegistry().bind("awsSesClient", awsSESClient);
         Ses2Component component = new Ses2Component(context);
-        Ses2Endpoint endpoint = (Ses2Endpoint) component.createEndpoint("aws2-ses://from@example.com");
+        Ses2Endpoint endpoint = (Ses2Endpoint) component.createEndpoint("aws2-ses://from@example.com?accessKey=xxx&secretKey=yyy");
 
         assertNotNull(endpoint.getConfiguration().getAmazonSESClient());
-        component.close();
     }
 
     @Test