camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [2/2] git commit: CAMEL-7286 polish the code of SnsEndpoint
Date Wed, 12 Mar 2014 07:53:25 GMT
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/c614b28e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c614b28e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c614b28e

Branch: refs/heads/master
Commit: c614b28e9d254cfdc3ffd2490812a90563c54d9d
Parents: 3ec500c
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Wed Mar 12 15:46:15 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Wed Mar 12 15:48:41 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/c614b28e/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


Mime
View raw message