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 2018/02/07 09:45:05 UTC
[camel] 08/10: CAMEL-12234 - Camel-AWS: Since we are using builders,
we need to remove the AWS endpoint options on the components that are using
them - AWS SNS
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 217aea5c32a9a64d05cceacc52fc20494bab634e
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Feb 7 10:32:15 2018 +0100
CAMEL-12234 - Camel-AWS: Since we are using builders, we need to remove the AWS endpoint options on the components that are using them - AWS SNS
---
components/camel-aws/src/main/docs/aws-sns-component.adoc | 5 ++---
.../apache/camel/component/aws/sns/SnsConfiguration.java | 13 -------------
.../org/apache/camel/component/aws/sns/SnsEndpoint.java | 7 +++----
.../component/aws/sns/SnsComponentConfigurationTest.java | 8 ++------
.../aws/sns/springboot/SnsComponentConfiguration.java | 12 ------------
5 files changed, 7 insertions(+), 38 deletions(-)
diff --git a/components/camel-aws/src/main/docs/aws-sns-component.adoc b/components/camel-aws/src/main/docs/aws-sns-component.adoc
index c7a7762..bc29847 100644
--- a/components/camel-aws/src/main/docs/aws-sns-component.adoc
+++ b/components/camel-aws/src/main/docs/aws-sns-component.adoc
@@ -65,13 +65,12 @@ with the following path and query parameters:
| *topicNameOrArn* | *Required* Topic name or ARN | | String
|===
-==== Query Parameters (12 parameters):
+==== Query Parameters (11 parameters):
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
| *amazonSNSClient* (producer) | To use the AmazonSNS as the client | | AmazonSNS
-| *amazonSNSEndpoint* (producer) | The region with which the AWS-SNS client wants to work with. | | String
| *headerFilterStrategy* (producer) | To use a custom HeaderFilterStrategy to map headers to/from Camel. | | HeaderFilterStrategy
| *messageStructure* (producer) | The message structure to use such as json | | String
| *policy* (producer) | The policy for this queue | | String
@@ -167,4 +166,4 @@ where `${camel-version`} must be replaced by the actual version of Camel
* link:endpoint.html[Endpoint]
* link:getting-started.html[Getting Started]
-* link:aws.html[AWS Component]
\ No newline at end of file
+* link:aws.html[AWS Component]
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsConfiguration.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsConfiguration.java
index 691fecf..dccb223 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsConfiguration.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsConfiguration.java
@@ -36,8 +36,6 @@ public class SnsConfiguration implements Cloneable {
@UriParam(label = "security", secret = true)
private String secretKey;
@UriParam
- private String amazonSNSEndpoint;
- @UriParam
private String proxyHost;
@UriParam
private Integer proxyPort;
@@ -52,17 +50,6 @@ public class SnsConfiguration implements Cloneable {
@UriParam
private String region;
- /**
- * The region with which the AWS-SNS client wants to work with.
- */
- public void setAmazonSNSEndpoint(String awsSNSEndpoint) {
- this.amazonSNSEndpoint = awsSNSEndpoint;
- }
-
- public String getAmazonSNSEndpoint() {
- return amazonSNSEndpoint;
- }
-
public String getSubject() {
return subject;
}
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsEndpoint.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsEndpoint.java
index 22ad83c..352ebb4 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsEndpoint.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsEndpoint.java
@@ -23,8 +23,8 @@ import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration;
+import com.amazonaws.regions.Regions;
import com.amazonaws.services.sns.AmazonSNS;
-import com.amazonaws.services.sns.AmazonSNSClient;
import com.amazonaws.services.sns.AmazonSNSClientBuilder;
import com.amazonaws.services.sns.model.CreateTopicRequest;
import com.amazonaws.services.sns.model.CreateTopicResult;
@@ -201,9 +201,8 @@ public class SnsEndpoint extends DefaultEndpoint implements HeaderFilterStrategy
clientBuilder = AmazonSNSClientBuilder.standard().withClientConfiguration(clientConfiguration);
}
}
- if (ObjectHelper.isNotEmpty(configuration.getAmazonSNSEndpoint()) && ObjectHelper.isNotEmpty(configuration.getRegion())) {
- EndpointConfiguration endpointConfiguration = new EndpointConfiguration(configuration.getAmazonSNSEndpoint(), configuration.getRegion());
- clientBuilder = clientBuilder.withEndpointConfiguration(endpointConfiguration);
+ if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
+ clientBuilder = clientBuilder.withRegion(Regions.valueOf(configuration.getRegion()));
}
client = clientBuilder.build();
return client;
diff --git a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java
index 52077c6..329263f 100644
--- a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java
+++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java
@@ -39,7 +39,6 @@ public class SnsComponentConfigurationTest extends CamelTestSupport {
assertNotNull(endpoint.getConfiguration().getAmazonSNSClient());
assertNull(endpoint.getConfiguration().getTopicArn());
assertNull(endpoint.getConfiguration().getSubject());
- assertNull(endpoint.getConfiguration().getAmazonSNSEndpoint());
assertNull(endpoint.getConfiguration().getPolicy());
}
@Test
@@ -53,7 +52,6 @@ public class SnsComponentConfigurationTest extends CamelTestSupport {
assertNull(endpoint.getConfiguration().getAmazonSNSClient());
assertNull(endpoint.getConfiguration().getTopicArn());
assertNull(endpoint.getConfiguration().getSubject());
- assertNull(endpoint.getConfiguration().getAmazonSNSEndpoint());
assertNull(endpoint.getConfiguration().getPolicy());
}
@@ -76,14 +74,13 @@ public class SnsComponentConfigurationTest extends CamelTestSupport {
((JndiRegistry) ((PropertyPlaceholderDelegateRegistry) context.getRegistry()).getRegistry()).bind("amazonSNSClient", mock);
SnsComponent component = new SnsComponent(context);
- SnsEndpoint endpoint = (SnsEndpoint) component.createEndpoint("aws-sns://MyTopic?amazonSNSClient=#amazonSNSClient&amazonSNSEndpoint=sns.ap-southeast-2.amazonaws.com");
+ SnsEndpoint endpoint = (SnsEndpoint) component.createEndpoint("aws-sns://MyTopic?amazonSNSClient=#amazonSNSClient");
assertEquals("MyTopic", endpoint.getConfiguration().getTopicName());
assertNull(endpoint.getConfiguration().getAccessKey());
assertNull(endpoint.getConfiguration().getSecretKey());
assertNull(endpoint.getConfiguration().getTopicArn());
assertNull(endpoint.getConfiguration().getSubject());
- assertNotNull(endpoint.getConfiguration().getAmazonSNSEndpoint());
assertNull(endpoint.getConfiguration().getPolicy());
endpoint.start();
@@ -102,12 +99,11 @@ public class SnsComponentConfigurationTest extends CamelTestSupport {
((JndiRegistry) ((PropertyPlaceholderDelegateRegistry) context.getRegistry()).getRegistry()).bind("amazonSNSClient", mock);
SnsComponent component = new SnsComponent(context);
- SnsEndpoint endpoint = (SnsEndpoint) component.createEndpoint("aws-sns://MyTopic?amazonSNSClient=#amazonSNSClient&amazonSNSEndpoint=sns.eu-west-1.amazonaws.com&accessKey=xxx&secretKey=yyy"
+ SnsEndpoint endpoint = (SnsEndpoint) component.createEndpoint("aws-sns://MyTopic?amazonSNSClient=#amazonSNSClient&accessKey=xxx&secretKey=yyy"
+ "&policy=%7B%22Version%22%3A%222008-10-17%22,%22Statement%22%3A%5B%7B%22Sid%22%3A%221%22,%22Effect%22%3A%22Allow%22,%22Principal%22%3A%7B%22AWS%22%3A%5B%22*%22%5D%7D,"
+ "%22Action%22%3A%5B%22sns%3ASubscribe%22%5D%7D%5D%7D&subject=The+subject+message");
assertEquals("MyTopic", endpoint.getConfiguration().getTopicName());
- assertEquals("sns.eu-west-1.amazonaws.com", endpoint.getConfiguration().getAmazonSNSEndpoint());
assertEquals("xxx", endpoint.getConfiguration().getAccessKey());
assertEquals("yyy", endpoint.getConfiguration().getSecretKey());
assertNull(endpoint.getConfiguration().getTopicArn());
diff --git a/platforms/spring-boot/components-starter/camel-aws-starter/src/main/java/org/apache/camel/component/aws/sns/springboot/SnsComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-aws-starter/src/main/java/org/apache/camel/component/aws/sns/springboot/SnsComponentConfiguration.java
index b5962a2..5065d24 100644
--- a/platforms/spring-boot/components-starter/camel-aws-starter/src/main/java/org/apache/camel/component/aws/sns/springboot/SnsComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-aws-starter/src/main/java/org/apache/camel/component/aws/sns/springboot/SnsComponentConfiguration.java
@@ -101,10 +101,6 @@ public class SnsComponentConfiguration
public static class SnsConfigurationNestedConfiguration {
public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.aws.sns.SnsConfiguration.class;
/**
- * The region with which the AWS-SNS client wants to work with.
- */
- private String amazonSNSEndpoint;
- /**
* The subject which is used if the message header 'CamelAwsSnsSubject'
* is not present.
*/
@@ -141,14 +137,6 @@ public class SnsComponentConfiguration
private Integer proxyPort;
private String region;
- public String getAmazonSNSEndpoint() {
- return amazonSNSEndpoint;
- }
-
- public void setAmazonSNSEndpoint(String amazonSNSEndpoint) {
- this.amazonSNSEndpoint = amazonSNSEndpoint;
- }
-
public String getSubject() {
return subject;
}
--
To stop receiving notification emails like this one, please contact
acosentino@apache.org.