camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [4/6] camel git commit: CAMEL-9045 Camel-aws: Make it easier to configure http proxy, aws-ec2 component
Date Sat, 01 Aug 2015 09:17:11 GMT
CAMEL-9045 Camel-aws: Make it easier to configure http proxy, aws-ec2 component


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

Branch: refs/heads/master
Commit: c09242987886c20ca0812a39e98a1d5911b56aa3
Parents: f95bfff
Author: Andrea Cosentino <ancosen@gmail.com>
Authored: Sat Aug 1 11:03:02 2015 +0200
Committer: Andrea Cosentino <ancosen@gmail.com>
Committed: Sat Aug 1 11:03:02 2015 +0200

----------------------------------------------------------------------
 .../component/aws/ec2/EC2Configuration.java     | 27 ++++++++++++++++++++
 .../camel/component/aws/ec2/EC2Endpoint.java    | 12 ++++++++-
 2 files changed, 38 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c0924298/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Configuration.java
----------------------------------------------------------------------
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Configuration.java
b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Configuration.java
index 2d57fde..aeaa47e 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Configuration.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Configuration.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.aws.ec2;
 
 import com.amazonaws.services.ec2.AmazonEC2Client;
+
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
@@ -37,6 +38,10 @@ public class EC2Configuration {
     private String amazonEc2Endpoint;
     @UriParam @Metadata(required = "true")
     private EC2Operations operation;
+    @UriParam
+    private String proxyHost;
+    @UriParam
+    private Integer proxyPort;
     
     public AmazonEC2Client getAmazonEc2Client() {
         return amazonEc2Client;
@@ -92,4 +97,26 @@ public class EC2Configuration {
     public void setOperation(EC2Operations operation) {
         this.operation = operation;
     } 
+    
+    /**
+     * To define a proxy host when instantiating the SQS client
+     */
+    public String getProxyHost() {
+        return proxyHost;
+    }
+
+    public void setProxyHost(String proxyHost) {
+        this.proxyHost = proxyHost;
+    }
+
+    /**
+     * To define a proxy port when instantiating the SQS client
+     */
+    public Integer getProxyPort() {
+        return proxyPort;
+    }
+
+    public void setProxyPort(Integer proxyPort) {
+        this.proxyPort = proxyPort;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/c0924298/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 c810666..c9e2904 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
@@ -16,9 +16,11 @@
  */
 package org.apache.camel.component.aws.ec2;
 
+import com.amazonaws.ClientConfiguration;
 import com.amazonaws.auth.AWSCredentials;
 import com.amazonaws.auth.BasicAWSCredentials;
 import com.amazonaws.services.ec2.AmazonEC2Client;
+
 import org.apache.camel.Component;
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
@@ -75,8 +77,16 @@ public class EC2Endpoint extends ScheduledPollEndpoint {
     }
 
     AmazonEC2Client createEc2Client() {
+        AmazonEC2Client client = null;
         AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(),
configuration.getSecretKey());
-        AmazonEC2Client client = new AmazonEC2Client(credentials);
+        if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort()))
{
+            ClientConfiguration clientConfiguration = new ClientConfiguration();
+            clientConfiguration.setProxyHost(configuration.getProxyHost());
+            clientConfiguration.setProxyPort(configuration.getProxyPort());
+            client = new AmazonEC2Client(credentials, clientConfiguration);
+        } else {
+            client = new AmazonEC2Client(credentials);
+        }
         return client;
     }
 }


Mime
View raw message