camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [4/8] camel git commit: CAMEL-11703 - Camel-AWS: Use builders instead of different constructors - AWS EC2
Date Fri, 25 Aug 2017 07:34:22 GMT
CAMEL-11703 - Camel-AWS: Use builders instead of different constructors - AWS EC2


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

Branch: refs/heads/master
Commit: c61244e38096931bef4314a4e659315d1470833c
Parents: fc2a2ca
Author: Andrea Cosentino <ancosen@gmail.com>
Authored: Fri Aug 25 08:56:02 2017 +0200
Committer: Andrea Cosentino <ancosen@gmail.com>
Committed: Fri Aug 25 09:33:29 2017 +0200

----------------------------------------------------------------------
 .../camel/component/aws/ec2/EC2Endpoint.java     | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c61244e3/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Endpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Endpoint.java
b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Endpoint.java
index f113447..2683c91 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Endpoint.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Endpoint.java
@@ -18,8 +18,12 @@ package org.apache.camel.component.aws.ec2;
 
 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.ec2.AmazonEC2;
 import com.amazonaws.services.ec2.AmazonEC2Client;
+import com.amazonaws.services.ec2.AmazonEC2ClientBuilder;
 
 import org.apache.camel.Component;
 import org.apache.camel.Consumer;
@@ -62,7 +66,7 @@ public class EC2Endpoint extends ScheduledPollEndpoint {
     public void doStart() throws Exception {
         super.doStart();
         
-        ec2Client = configuration.getAmazonEc2Client() != null ? configuration.getAmazonEc2Client()
: createEc2Client();
+        ec2Client = configuration.getAmazonEc2Client() != null ? configuration.getAmazonEc2Client()
: (AmazonEC2Client) createEc2Client();
         if (ObjectHelper.isNotEmpty(configuration.getAmazonEc2Endpoint())) {
             ec2Client.setEndpoint(configuration.getAmazonEc2Endpoint());
         }
@@ -76,8 +80,8 @@ public class EC2Endpoint extends ScheduledPollEndpoint {
         return ec2Client;
     }
 
-    AmazonEC2Client createEc2Client() {
-        AmazonEC2Client client = null;
+    AmazonEC2 createEc2Client() {
+        AmazonEC2 client = null;
         ClientConfiguration clientConfiguration = null;
         boolean isClientConfigFound = false;
         if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort()))
{
@@ -88,16 +92,17 @@ public class EC2Endpoint 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 AmazonEC2Client(credentials, clientConfiguration);
+                client = AmazonEC2ClientBuilder.standard().withClientConfiguration(clientConfiguration).withCredentials(credentialsProvider).build();
             } else {
-                client = new AmazonEC2Client(credentials);
+                client = AmazonEC2ClientBuilder.standard().withCredentials(credentialsProvider).build();
             }
         } else {
             if (isClientConfigFound) {
-                client = new AmazonEC2Client();
+                client = AmazonEC2ClientBuilder.standard().build();
             } else {
-                client = new AmazonEC2Client(clientConfiguration);
+                client = AmazonEC2ClientBuilder.standard().withClientConfiguration(clientConfiguration).build();
             }
         }
         return client;


Mime
View raw message