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 2019/12/11 12:49:10 UTC

[camel] branch master updated (b862e01 -> b8bf160)

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 b862e01  CAMEL-14284: Configuring endpoint should set properties on endpoint and not configuration object - aws-lambda
     new 54a694e  CAMEL-14284: Configuring endpoint should set properties on endpoint and not configuration object - aws-mq
     new b8bf160  CAMEL-14284: Configuring endpoint should set properties on endpoint and not configuration object - aws-msk

The 2 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/component/aws/mq/MQComponent.java | 33 ++++++++-------------
 .../aws/mq/MQComponentClientRegistryTest.java      |  4 +--
 .../aws/mq/MQComponentConfigurationTest.java       |  6 ++--
 .../camel/component/aws/msk/MSKComponent.java      | 34 ++++++++--------------
 .../aws/msk/MSKComponentClientRegistryTest.java    |  4 +--
 .../aws/msk/MSKComponentConfigurationTest.java     |  6 ++--
 6 files changed, 34 insertions(+), 53 deletions(-)


[camel] 02/02: CAMEL-14284: Configuring endpoint should set properties on endpoint and not configuration object - aws-msk

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 b8bf160f909dbd2f955dc117cc5ffe517e6c3492
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Dec 11 13:47:31 2019 +0100

    CAMEL-14284: Configuring endpoint should set properties on endpoint and not configuration object - aws-msk
---
 .../camel/component/aws/msk/MSKComponent.java      | 34 ++++++++--------------
 .../aws/msk/MSKComponentClientRegistryTest.java    |  4 +--
 .../aws/msk/MSKComponentConfigurationTest.java     |  6 ++--
 3 files changed, 17 insertions(+), 27 deletions(-)

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 a220477..a5b4285 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
@@ -25,7 +25,6 @@ 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;
 
 /**
  * For working with Amazon MSK.
@@ -49,30 +48,21 @@ public class MSKComponent extends DefaultComponent {
     public MSKComponent(CamelContext context) {
         super(context);
         
-        this.configuration = new MSKConfiguration();
         registerExtension(new MSKComponentVerifierExtension());
     }
 
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
-        MSKConfiguration configuration = this.configuration.copy();
-        setProperties(configuration, parameters);
-
-        if (ObjectHelper.isEmpty(configuration.getAccessKey())) {
-            setAccessKey(accessKey);
-        }
-        if (ObjectHelper.isEmpty(configuration.getSecretKey())) {
-            setSecretKey(secretKey);
-        }
-        if (ObjectHelper.isEmpty(configuration.getRegion())) {
-            setRegion(region);
-        }
+        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)) {
             throw new IllegalArgumentException("Amazon msk client or accessKey and secretKey must be specified");
         }
-        
-        MSKEndpoint endpoint = new MSKEndpoint(uri, this, configuration);
         return endpoint;
     }
     
@@ -88,36 +78,36 @@ public class MSKComponent extends DefaultComponent {
     }
 
     public String getAccessKey() {
-        return configuration.getAccessKey();
+        return accessKey;
     }
 
     /**
      * Amazon AWS Access Key
      */
     public void setAccessKey(String accessKey) {
-        configuration.setAccessKey(accessKey);
+        this.accessKey = accessKey;
     }
 
     public String getSecretKey() {
-        return configuration.getSecretKey();
+        return secretKey;
     }
 
     /**
      * Amazon AWS Secret Key
      */
     public void setSecretKey(String secretKey) {
-        configuration.setSecretKey(secretKey);
+        this.secretKey = secretKey;
     }
     
     public String getRegion() {
-        return configuration.getRegion();
+        return region;
     }
 
     /**
      * The region in which MSK client needs to work
      */
     public void setRegion(String region) {
-        configuration.setRegion(region);
+        this.region = region;
     }
 
     private void checkAndSetRegistryClient(MSKConfiguration configuration) {
diff --git a/components/camel-aws-msk/src/test/java/org/apache/camel/component/aws/msk/MSKComponentClientRegistryTest.java b/components/camel-aws-msk/src/test/java/org/apache/camel/component/aws/msk/MSKComponentClientRegistryTest.java
index 85f04a8..c94a568 100644
--- a/components/camel-aws-msk/src/test/java/org/apache/camel/component/aws/msk/MSKComponentClientRegistryTest.java
+++ b/components/camel-aws-msk/src/test/java/org/apache/camel/component/aws/msk/MSKComponentClientRegistryTest.java
@@ -26,7 +26,7 @@ public class MSKComponentClientRegistryTest extends CamelTestSupport {
 
         AmazonMSKClientMock awsMSKClient = new AmazonMSKClientMock();
         context.getRegistry().bind("awsMskClient", awsMSKClient);
-        MSKComponent component = new MSKComponent(context);
+        MSKComponent component = context.getComponent("aws-msk", MSKComponent.class);
         MSKEndpoint endpoint = (MSKEndpoint) component.createEndpoint("aws-msk://label");
 
         assertNotNull(endpoint.getConfiguration().getMskClient());
@@ -35,7 +35,7 @@ public class MSKComponentClientRegistryTest extends CamelTestSupport {
     @Test(expected = IllegalArgumentException.class)
     public void createEndpointWithMinimalMSKClientMisconfiguration() throws Exception {
 
-        MSKComponent component = new MSKComponent(context);
+        MSKComponent component = context.getComponent("aws-msk", MSKComponent.class);
         MSKEndpoint endpoint = (MSKEndpoint) component.createEndpoint("aws-msk://label");
     }
 }
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 1e06de3..9f68f72 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
@@ -25,7 +25,7 @@ public class MSKComponentConfigurationTest extends CamelTestSupport {
 
     @Test
     public void createEndpointWithComponentElements() throws Exception {
-        MSKComponent component = new MSKComponent(context);
+        MSKComponent component = context.getComponent("aws-msk", MSKComponent.class);
         component.setAccessKey("XXX");
         component.setSecretKey("YYY");
         MSKEndpoint endpoint = (MSKEndpoint)component.createEndpoint("aws-msk://label");
@@ -36,7 +36,7 @@ public class MSKComponentConfigurationTest extends CamelTestSupport {
 
     @Test
     public void createEndpointWithComponentAndEndpointElements() throws Exception {
-        MSKComponent component = new MSKComponent(context);
+        MSKComponent component = context.getComponent("aws-msk", MSKComponent.class);
         component.setAccessKey("XXX");
         component.setSecretKey("YYY");
         component.setRegion(Regions.US_WEST_1.toString());
@@ -49,7 +49,7 @@ public class MSKComponentConfigurationTest extends CamelTestSupport {
 
     @Test
     public void createEndpointWithComponentEndpointElementsAndProxy() throws Exception {
-        MSKComponent component = new MSKComponent(context);
+        MSKComponent component = context.getComponent("aws-msk", MSKComponent.class);
         component.setAccessKey("XXX");
         component.setSecretKey("YYY");
         component.setRegion(Regions.US_WEST_1.toString());


[camel] 01/02: CAMEL-14284: Configuring endpoint should set properties on endpoint and not configuration object - aws-mq

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 54a694e4522772d9d3ca5ad568bbec8ab4b9251e
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Dec 11 13:42:20 2019 +0100

    CAMEL-14284: Configuring endpoint should set properties on endpoint and not configuration object - aws-mq
---
 .../apache/camel/component/aws/mq/MQComponent.java | 33 ++++++++--------------
 .../aws/mq/MQComponentClientRegistryTest.java      |  4 +--
 .../aws/mq/MQComponentConfigurationTest.java       |  6 ++--
 3 files changed, 17 insertions(+), 26 deletions(-)

diff --git a/components/camel-aws-mq/src/main/java/org/apache/camel/component/aws/mq/MQComponent.java b/components/camel-aws-mq/src/main/java/org/apache/camel/component/aws/mq/MQComponent.java
index 868806e..a6b07d8 100644
--- a/components/camel-aws-mq/src/main/java/org/apache/camel/component/aws/mq/MQComponent.java
+++ b/components/camel-aws-mq/src/main/java/org/apache/camel/component/aws/mq/MQComponent.java
@@ -25,7 +25,6 @@ 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;
 
 /**
  * For working with Amazon MQ.
@@ -49,30 +48,22 @@ public class MQComponent extends DefaultComponent {
     public MQComponent(CamelContext context) {
         super(context);
         
-        this.configuration = new MQConfiguration();
         registerExtension(new MQComponentVerifierExtension());
     }
 
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
-        MQConfiguration configuration = this.configuration.copy();
-        setProperties(configuration, parameters);
-
-        if (ObjectHelper.isEmpty(configuration.getAccessKey())) {
-            setAccessKey(accessKey);
-        }
-        if (ObjectHelper.isEmpty(configuration.getSecretKey())) {
-            setSecretKey(secretKey);
-        }
-        if (ObjectHelper.isEmpty(configuration.getRegion())) {
-            setRegion(region);
-        }
+        MQConfiguration configuration = this.configuration != null ? this.configuration.copy() : new MQConfiguration();
+        MQEndpoint endpoint = new MQEndpoint(uri, this, configuration);
+        endpoint.getConfiguration().setAccessKey(accessKey);
+        endpoint.getConfiguration().setSecretKey(secretKey);
+        endpoint.getConfiguration().setRegion(region);
+        setProperties(endpoint, parameters);
         checkAndSetRegistryClient(configuration);
         if (configuration.getAmazonMqClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
             throw new IllegalArgumentException("amazonMQClient or accessKey and secretKey must be specified");
         }
         
-        MQEndpoint endpoint = new MQEndpoint(uri, this, configuration);
         return endpoint;
     }
     
@@ -88,36 +79,36 @@ public class MQComponent extends DefaultComponent {
     }
 
     public String getAccessKey() {
-        return configuration.getAccessKey();
+        return accessKey;
     }
 
     /**
      * Amazon AWS Access Key
      */
     public void setAccessKey(String accessKey) {
-        configuration.setAccessKey(accessKey);
+        this.accessKey = accessKey;
     }
 
     public String getSecretKey() {
-        return configuration.getSecretKey();
+        return secretKey;
     }
 
     /**
      * Amazon AWS Secret Key
      */
     public void setSecretKey(String secretKey) {
-        configuration.setSecretKey(secretKey);
+        this.secretKey = secretKey;
     }
     
     public String getRegion() {
-        return configuration.getRegion();
+        return region;
     }
 
     /**
      * The region in which MQ client needs to work
      */
     public void setRegion(String region) {
-        configuration.setRegion(region);
+        this.region = region;
     }
 
     private void checkAndSetRegistryClient(MQConfiguration configuration) {
diff --git a/components/camel-aws-mq/src/test/java/org/apache/camel/component/aws/mq/MQComponentClientRegistryTest.java b/components/camel-aws-mq/src/test/java/org/apache/camel/component/aws/mq/MQComponentClientRegistryTest.java
index 9734e8b..80fcafd 100644
--- a/components/camel-aws-mq/src/test/java/org/apache/camel/component/aws/mq/MQComponentClientRegistryTest.java
+++ b/components/camel-aws-mq/src/test/java/org/apache/camel/component/aws/mq/MQComponentClientRegistryTest.java
@@ -26,7 +26,7 @@ public class MQComponentClientRegistryTest extends CamelTestSupport {
 
         AmazonMQClientMock awsMQClient = new AmazonMQClientMock();
         context.getRegistry().bind("awsMQClient", awsMQClient);
-        MQComponent component = new MQComponent(context);
+        MQComponent component = context.getComponent("aws-mq", MQComponent.class);
         MQEndpoint endpoint = (MQEndpoint) component.createEndpoint("aws-mq://MyQueue");
 
         assertNotNull(endpoint.getConfiguration().getAmazonMqClient());
@@ -35,7 +35,7 @@ public class MQComponentClientRegistryTest extends CamelTestSupport {
     @Test(expected = IllegalArgumentException.class)
     public void createEndpointWithMinimalMQClientMisconfiguration() throws Exception {
 
-        MQComponent component = new MQComponent(context);
+        MQComponent component = context.getComponent("aws-mq", MQComponent.class);
         MQEndpoint endpoint = (MQEndpoint) component.createEndpoint("aws-mq://MyQueue");
     }
 }
diff --git a/components/camel-aws-mq/src/test/java/org/apache/camel/component/aws/mq/MQComponentConfigurationTest.java b/components/camel-aws-mq/src/test/java/org/apache/camel/component/aws/mq/MQComponentConfigurationTest.java
index 0617832..5f4560f 100644
--- a/components/camel-aws-mq/src/test/java/org/apache/camel/component/aws/mq/MQComponentConfigurationTest.java
+++ b/components/camel-aws-mq/src/test/java/org/apache/camel/component/aws/mq/MQComponentConfigurationTest.java
@@ -26,7 +26,7 @@ public class MQComponentConfigurationTest extends CamelTestSupport {
     
     @Test
     public void createEndpointWithComponentElements() throws Exception {
-        MQComponent component = new MQComponent(context);
+        MQComponent component = context.getComponent("aws-mq", MQComponent.class);
         component.setAccessKey("XXX");
         component.setSecretKey("YYY");
         MQEndpoint endpoint = (MQEndpoint)component.createEndpoint("aws-mq://MyQueue");
@@ -37,7 +37,7 @@ public class MQComponentConfigurationTest extends CamelTestSupport {
     
     @Test
     public void createEndpointWithComponentAndEndpointElements() throws Exception {
-        MQComponent component = new MQComponent(context);
+        MQComponent component = context.getComponent("aws-mq", MQComponent.class);
         component.setAccessKey("XXX");
         component.setSecretKey("YYY");
         component.setRegion(Regions.US_WEST_1.toString());
@@ -50,7 +50,7 @@ public class MQComponentConfigurationTest extends CamelTestSupport {
 
     @Test
     public void createEndpointWithComponentEndpointElementsAndProxy() throws Exception {
-        MQComponent component = new MQComponent(context);
+        MQComponent component = context.getComponent("aws-mq", MQComponent.class);
         component.setAccessKey("XXX");
         component.setSecretKey("YYY");
         component.setRegion(Regions.US_WEST_1.toString());