Repository: camel Updated Branches: refs/heads/camel-2.11.x 275bcbe97 -> 90d9611c9 refs/heads/camel-2.12.x 6936213d2 -> e170feb3a
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/5ac52498 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5ac52498 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5ac52498 Branch: refs/heads/camel-2.12.x Commit: 5ac52498abd5dfd968acbd4e2da784364c78e56b Parents: 6936213 Author: Willem Jiang <willem.ji...@gmail.com> Authored: Wed Mar 12 15:46:15 2014 +0800 Committer: Willem Jiang <willem.ji...@gmail.com> Committed: Wed Mar 12 15:55:26 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/5ac52498/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