CAMEL-11703 - Camel-AWS: Use builders instead of different constructors - AWS CloudWatch
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1e02d37c Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1e02d37c Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1e02d37c Branch: refs/heads/master Commit: 1e02d37c44b9a6955c51379f506f02ba3828b80c Parents: 2e2df2c Author: Andrea Cosentino <[email protected]> Authored: Fri Aug 25 08:42:20 2017 +0200 Committer: Andrea Cosentino <[email protected]> Committed: Fri Aug 25 09:33:29 2017 +0200 ---------------------------------------------------------------------- .../org/apache/camel/component/aws/cw/CwEndpoint.java | 13 ++++++++----- .../org/apache/camel/component/aws/s3/S3Endpoint.java | 6 +++--- 2 files changed, 11 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/1e02d37c/components/camel-aws/src/main/java/org/apache/camel/component/aws/cw/CwEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/cw/CwEndpoint.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/cw/CwEndpoint.java index 22bce76..e75d225 100644 --- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/cw/CwEndpoint.java +++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/cw/CwEndpoint.java @@ -18,9 +18,11 @@ package org.apache.camel.component.aws.cw; import com.amazonaws.ClientConfiguration; import com.amazonaws.auth.AWSCredentials; +import com.amazonaws.auth.AWSCredentialsProvider; +import com.amazonaws.auth.AWSStaticCredentialsProvider; import com.amazonaws.auth.BasicAWSCredentials; import com.amazonaws.services.cloudwatch.AmazonCloudWatch; -import com.amazonaws.services.cloudwatch.AmazonCloudWatchClient; +import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder; import org.apache.camel.CamelContext; import org.apache.camel.Component; @@ -105,16 +107,17 @@ public class CwEndpoint extends DefaultEndpoint { } if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) { AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey()); + AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials); if (isClientConfigFound) { - client = new AmazonCloudWatchClient(credentials, clientConfiguration); + client = AmazonCloudWatchClientBuilder.standard().withClientConfiguration(clientConfiguration).withCredentials(credentialsProvider).build(); } else { - client = new AmazonCloudWatchClient(credentials); + client = AmazonCloudWatchClientBuilder.standard().withCredentials(credentialsProvider).build(); } } else { if (isClientConfigFound) { - client = new AmazonCloudWatchClient(); + client = AmazonCloudWatchClientBuilder.standard().build(); } else { - client = new AmazonCloudWatchClient(clientConfiguration); + client = AmazonCloudWatchClientBuilder.standard().withClientConfiguration(clientConfiguration).build(); } } return client; http://git-wip-us.apache.org/repos/asf/camel/blob/1e02d37c/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Endpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Endpoint.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Endpoint.java index 6f06177..df9538a 100644 --- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Endpoint.java +++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Endpoint.java @@ -255,15 +255,15 @@ public class S3Endpoint extends ScheduledPollEndpoint { AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey()); AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials); if (isClientConfigFound) { - client = AmazonS3ClientBuilder.standard().withClientConfiguration(clientConfiguration).withCredentials(credentialsProvider).build(); + client = AmazonS3ClientBuilder.standard().withClientConfiguration(clientConfiguration).withCredentials(credentialsProvider).build(); } else { client = AmazonS3ClientBuilder.standard().withCredentials(credentialsProvider).build(); } } else { if (isClientConfigFound) { - client = AmazonS3ClientBuilder.standard().build(); + client = AmazonS3ClientBuilder.standard().build(); } else { - client = AmazonS3ClientBuilder.standard().withClientConfiguration(clientConfiguration).build(); + client = AmazonS3ClientBuilder.standard().withClientConfiguration(clientConfiguration).build(); } }
