cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject [1/2] cxf git commit: [CXF-6353] Support for HTTP proxy properties
Date Mon, 20 Apr 2015 11:39:49 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 646424838 -> 1731258de


[CXF-6353] Support for HTTP proxy properties


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

Branch: refs/heads/3.0.x-fixes
Commit: f3eaa61a2ac9c9a22b31519bbe0dc92f9cf84219
Parents: 6464248
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Fri Apr 17 17:29:28 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Fri Apr 17 17:30:49 2015 +0100

----------------------------------------------------------------------
 .../cxf/jaxrs/client/spec/ClientImpl.java       | 30 ++++++++++++++++----
 1 file changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/f3eaa61a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java
index 95c7650..f19a32f 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java
@@ -50,6 +50,8 @@ import org.apache.cxf.transport.https.SSLUtils;
 public class ClientImpl implements Client {
     private static final String HTTP_CONNECTION_TIMEOUT_PROP = "http.connection.timeout";
     private static final String HTTP_RECEIVE_TIMEOUT_PROP = "http.receive.timeout";
+    private static final String HTTP_PROXY_SERVER_PROP = "http.proxy.server.uri";
+    private static final String HTTP_PROXY_SERVER_PORT_PROP = "http.proxy.server.port";
     
     private Configurable<Client> configImpl;
     private TLSConfiguration secConfig;
@@ -271,6 +273,13 @@ public class ClientImpl implements Client {
                 || tlsParams.getTrustManagers() != null) {
                 clientCfg.getHttpConduit().setTlsClientParameters(tlsParams);
             }
+            
+            setConnectionProperties(configProps, clientCfg);
+            
+            // start building the invocation
+            return new InvocationBuilderImpl(WebClient.fromClient(targetClient));
+        }
+        private void setConnectionProperties(Map<String, Object> configProps, ClientConfiguration
clientCfg) {
             Long connTimeOutValue = getLongValue(configProps.get(HTTP_CONNECTION_TIMEOUT_PROP));
             if (connTimeOutValue != null) {
                 clientCfg.getHttpConduit().getClient().setConnectionTimeout(connTimeOutValue);
@@ -279,13 +288,16 @@ public class ClientImpl implements Client {
             if (recTimeOutValue != null) {
                 clientCfg.getHttpConduit().getClient().setReceiveTimeout(recTimeOutValue);
             }
-            
-            // start building the invocation
-            return new InvocationBuilderImpl(WebClient.fromClient(targetClient));
-        }
-        private Long getLongValue(Object o) {
-            return o instanceof Long ? (Long)o : o instanceof String ? Long.valueOf(o.toString())
: null;
+            Object proxyServerValue = configProps.get(HTTP_PROXY_SERVER_PROP);
+            if (proxyServerValue != null) {
+                clientCfg.getHttpConduit().getClient().setProxyServer((String)proxyServerValue);
+            }
+            Integer proxyServerPortValue = getIntValue(configProps.get(HTTP_PROXY_SERVER_PORT_PROP));
+            if (proxyServerPortValue != null) {
+                clientCfg.getHttpConduit().getClient().setProxyServerPort(proxyServerPortValue);
+            }
         }
+
         private void initTargetClientIfNeeded() {
             URI uri = uriBuilder.build();
             if (targetClient == null) {
@@ -483,4 +495,10 @@ public class ClientImpl implements Client {
             checkNull(templatesMap.values().toArray());
         }
     }
+    private static Long getLongValue(Object o) {
+        return o instanceof Long ? (Long)o : o instanceof String ? Long.valueOf(o.toString())
: null;
+    }
+    private static Integer getIntValue(Object o) {
+        return o instanceof Integer ? (Integer)o : o instanceof String ? Integer.valueOf(o.toString())
: null;
+    }
 }


Mime
View raw message