You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/03/12 09:22:28 UTC
[3/4] git commit: CAMEL-7286 polish the code of SnsEndpoint
CAMEL-7286 polish the code of SnsEndpoint
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/92fa48cd
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/92fa48cd
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/92fa48cd
Branch: refs/heads/camel-2.11.x
Commit: 92fa48cd455ad286ab4cbca83d6598360051f473
Parents: 275bcbe
Author: Willem Jiang <wi...@gmail.com>
Authored: Wed Mar 12 15:46:15 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Wed Mar 12 16:05:07 2014 +0800
----------------------------------------------------------------------
.../camel/component/aws/sns/SnsEndpoint.java | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/92fa48cd/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsEndpoint.java
----------------------------------------------------------------------
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 63c5046..031d112 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
@@ -70,13 +70,14 @@ public class SnsEndpoint extends DefaultEndpoint {
@Override
public void doStart() throws Exception {
super.doStart();
-
+ snsClient = configuration.getAmazonSNSClient() != null
+ ? configuration.getAmazonSNSClient() : createSNSClient();
// creates a new topic, or returns the URL of an existing one
CreateTopicRequest request = new CreateTopicRequest(configuration.getTopicName());
LOG.trace("Creating topic [{}] with request [{}]...", configuration.getTopicName(), request);
- CreateTopicResult result = getSNSClient().createTopic(request);
+ CreateTopicResult result = snsClient.createTopic(request);
configuration.setTopicArn(result.getTopicArn());
LOG.trace("Topic created with Amazon resource name: {}", configuration.getTopicArn());
@@ -84,14 +85,14 @@ public class SnsEndpoint extends DefaultEndpoint {
if (ObjectHelper.isNotEmpty(configuration.getPolicy())) {
LOG.trace("Updating topic [{}] with policy [{}]", configuration.getTopicArn(), configuration.getPolicy());
- getSNSClient().setTopicAttributes(new SetTopicAttributesRequest(configuration.getTopicArn(), "Policy", configuration.getPolicy()));
+ snsClient.setTopicAttributes(new SetTopicAttributesRequest(configuration.getTopicArn(), "Policy", configuration.getPolicy()));
LOG.trace("Topic policy updated");
}
-
+ // Override the setting Endpoint from url
if (ObjectHelper.isNotEmpty(configuration.getAmazonSNSEndpoint())) {
LOG.trace("Updating the SNS region with : {} " + configuration.getAmazonSNSEndpoint());
- getSNSClient().setEndpoint(configuration.getAmazonSNSEndpoint());
+ snsClient.setEndpoint(configuration.getAmazonSNSEndpoint());
}
}
@@ -108,11 +109,6 @@ public class SnsEndpoint extends DefaultEndpoint {
}
public AmazonSNS getSNSClient() {
- if (snsClient == null) {
- snsClient = configuration.getAmazonSNSClient() != null
- ? configuration.getAmazonSNSClient() : createSNSClient();
- }
-
return snsClient;
}
@@ -124,9 +120,6 @@ public class SnsEndpoint extends DefaultEndpoint {
AmazonSNS createSNSClient() {
AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
AmazonSNS client = new AmazonSNSClient(credentials);
- if (configuration.getAmazonSNSEndpoint() != null) {
- client.setEndpoint(configuration.getAmazonSNSEndpoint());
- }
return client;
}
}
\ No newline at end of file