You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2015/04/17 18:29:48 UTC

cxf git commit: [CXF-6353] Support for HTTP proxy properties

Repository: cxf
Updated Branches:
  refs/heads/master 0a900283e -> 071545f1e


[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/071545f1
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/071545f1
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/071545f1

Branch: refs/heads/master
Commit: 071545f1ea83650da2624ebde2bedbdef7ebb4cc
Parents: 0a90028
Author: Sergey Beryozkin <sb...@talend.com>
Authored: Fri Apr 17 17:29:28 2015 +0100
Committer: Sergey Beryozkin <sb...@talend.com>
Committed: Fri Apr 17 17:29:28 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/071545f1/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;
+    }
 }