CAMEL-11703 - Camel-AWS: Use builders instead of different constructors - AWS 
DynamoDB


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/fc2a2ca0
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/fc2a2ca0
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/fc2a2ca0

Branch: refs/heads/master
Commit: fc2a2ca0428c4ca4224291f85b5093aba0814b49
Parents: 1e02d37
Author: Andrea Cosentino <[email protected]>
Authored: Fri Aug 25 08:48:29 2017 +0200
Committer: Andrea Cosentino <[email protected]>
Committed: Fri Aug 25 09:33:29 2017 +0200

----------------------------------------------------------------------
 .../org/apache/camel/component/aws/ddb/DdbEndpoint.java | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/fc2a2ca0/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbEndpoint.java
----------------------------------------------------------------------
diff --git 
a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbEndpoint.java
 
b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbEndpoint.java
index 44c58f6..7c201dd 100644
--- 
a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbEndpoint.java
+++ 
b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbEndpoint.java
@@ -19,9 +19,12 @@ package org.apache.camel.component.aws.ddb;
 import com.amazonaws.AmazonServiceException;
 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.dynamodbv2.AmazonDynamoDB;
 import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient;
+import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
 import com.amazonaws.services.dynamodbv2.model.CreateTableRequest;
 import com.amazonaws.services.dynamodbv2.model.DescribeTableRequest;
 import com.amazonaws.services.dynamodbv2.model.KeySchemaElement;
@@ -145,16 +148,17 @@ public class DdbEndpoint extends ScheduledPollEndpoint {
         }
         if (configuration.getAccessKey() != null && 
configuration.getSecretKey() != null) {
             AWSCredentials credentials = new 
BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
+            AWSCredentialsProvider credentialsProvider = new 
AWSStaticCredentialsProvider(credentials);
             if (isClientConfigFound) {
-                client = new AmazonDynamoDBClient(credentials, 
clientConfiguration);
+                client = 
AmazonDynamoDBClientBuilder.standard().withClientConfiguration(clientConfiguration).withCredentials(credentialsProvider).build();
             } else {
-                client = new AmazonDynamoDBClient(credentials);
+                client = 
AmazonDynamoDBClientBuilder.standard().withCredentials(credentialsProvider).build();
             }
         } else {
             if (isClientConfigFound) {
-                client = new AmazonDynamoDBClient();
+                client = AmazonDynamoDBClientBuilder.standard().build();
             } else {
-                client = new AmazonDynamoDBClient(clientConfiguration);
+                client = 
AmazonDynamoDBClientBuilder.standard().withClientConfiguration(clientConfiguration).build();
             }
         }
         return client;

Reply via email to