camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] camel git commit: CAMEL-9430 - Add proxy support
Date Wed, 10 Feb 2016 10:30:52 GMT
Repository: camel
Updated Branches:
  refs/heads/master 2b4b9df67 -> 821e9f48b


CAMEL-9430 - Add proxy support


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

Branch: refs/heads/master
Commit: c653560badeebcca114fac64d07a1ddc11025241
Parents: 2b4b9df
Author: lburgazzoli <lburgazzoli@gmail.com>
Authored: Wed Feb 10 10:15:26 2016 +0100
Committer: lburgazzoli <lburgazzoli@gmail.com>
Committed: Wed Feb 10 10:15:26 2016 +0100

----------------------------------------------------------------------
 .../braintree/BraintreeConfiguration.java       | 54 +++++++++++++++-----
 1 file changed, 41 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c653560b/components/camel-braintree/src/main/java/org/apache/camel/component/braintree/BraintreeConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-braintree/src/main/java/org/apache/camel/component/braintree/BraintreeConfiguration.java
b/components/camel-braintree/src/main/java/org/apache/camel/component/braintree/BraintreeConfiguration.java
index 08923b8..e366c2c 100644
--- a/components/camel-braintree/src/main/java/org/apache/camel/component/braintree/BraintreeConfiguration.java
+++ b/components/camel-braintree/src/main/java/org/apache/camel/component/braintree/BraintreeConfiguration.java
@@ -22,20 +22,15 @@ import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
 import org.apache.camel.util.ObjectHelper;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * Component configuration for Braintree component.
  */
 @UriParams
 public class BraintreeConfiguration {
-    private static final Logger LOG = LoggerFactory.getLogger(BraintreeConfiguration.class);
-
     private static final String ENVIRONMENT = "environment";
     private static final String MERCHANT_ID = "merchant_id";
-    private static final String PUBLIC_KEY = "public_key";
+    private static final String PUBLIC_KEY  = "public_key";
     private static final String PRIVATE_KEY = "private_key";
 
     @UriParam
@@ -54,6 +49,14 @@ public class BraintreeConfiguration {
     @Metadata(required = "true")
     private String privateKey;
 
+    @UriParam
+    @Metadata(label = "proxy")
+    private String proxyHost;
+
+    @UriParam
+    @Metadata(label = "proxy")
+    private Integer proxyPort;
+
     public String getEnvironment() {
         return ObjectHelper.notNull(environment, ENVIRONMENT);
     }
@@ -98,21 +101,41 @@ public class BraintreeConfiguration {
         this.privateKey = privateKey;
     }
 
+    public String getProxyHost() {
+        return proxyHost;
+    }
+
+    /**
+     * The proxy host
+     */
+    public void setProxyHost(String proxyHost) {
+        this.proxyHost = proxyHost;
+    }
+
+    public Integer getProxyPort() {
+        return proxyPort;
+    }
+
+    /**
+     * The proxy port
+     */
+    public void setProxyPort(Integer proxyPort) {
+        this.proxyPort = proxyPort;
+    }
+
     /**
      * Helper method to get and Environment object from its name
      */
     private Environment getBraintreeEnvironment() {
         String name = getEnvironment();
 
-        if (StringUtils.equalsIgnoreCase("development", name)) {
+        if (Environment.DEVELOPMENT.getEnvironmentName().equalsIgnoreCase(name)) {
             return Environment.DEVELOPMENT;
         }
-
-        if (StringUtils.equalsIgnoreCase("sandbox", name)) {
+        if (Environment.SANDBOX.getEnvironmentName().equalsIgnoreCase(name)) {
             return Environment.SANDBOX;
         }
-
-        if (StringUtils.equalsIgnoreCase("production", name)) {
+        if (Environment.PRODUCTION.getEnvironmentName().equalsIgnoreCase(name)) {
             return Environment.PRODUCTION;
         }
 
@@ -124,11 +147,16 @@ public class BraintreeConfiguration {
      * Construct a BraintreeGateway from configuration
      */
     BraintreeGateway newBraintreeGateway() {
-        return new BraintreeGateway(
+        final BraintreeGateway gateway = new BraintreeGateway(
             getBraintreeEnvironment(),
             getMerchantId(),
             getPublicKey(),
             getPrivateKey());
-    }
 
+        if (ObjectHelper.isNotEmpty(proxyHost) && ObjectHelper.isNotEmpty(proxyPort))
{
+            gateway.setProxy(proxyHost, proxyPort);
+        }
+
+        return gateway;
+    }
 }


Mime
View raw message