cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6353] Support for setting HTTP connection properties as JAX-RS 2.0 properties
Date Fri, 17 Apr 2015 16:00:07 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 43460c235 -> 0a900283e


[CXF-6353] Support for setting HTTP connection properties as JAX-RS 2.0 properties


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

Branch: refs/heads/master
Commit: 0a900283eb743516e66c5988700b002e40c1bf45
Parents: 43460c2
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Fri Apr 17 16:59:48 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Fri Apr 17 16:59:48 2015 +0100

----------------------------------------------------------------------
 .../cxf/jaxrs/client/spec/ClientImpl.java       | 27 ++++++++++++++++----
 1 file changed, 22 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/0a900283/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 ba9dc23..95c7650 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
@@ -40,6 +40,7 @@ import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.UriBuilder;
 
 import org.apache.cxf.configuration.jsse.TLSClientParameters;
+import org.apache.cxf.jaxrs.client.ClientConfiguration;
 import org.apache.cxf.jaxrs.client.ClientProviderFactory;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
 import org.apache.cxf.jaxrs.client.WebClient;
@@ -47,6 +48,9 @@ import org.apache.cxf.jaxrs.model.FilterProviderInfo;
 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 Configurable<Client> configImpl;
     private TLSConfiguration secConfig;
     private boolean closed;
@@ -254,21 +258,34 @@ public class ClientImpl implements Client {
             }
             
             pf.setUserProviders(providers);
-            WebClient.getConfig(targetClient).getRequestContext().putAll(getConfiguration().getProperties());
-            WebClient.getConfig(targetClient).getRequestContext().put(Client.class.getName(),
ClientImpl.this);
-            WebClient.getConfig(targetClient).getRequestContext().put(Configuration.class.getName(),

+            Map<String, Object> configProps = getConfiguration().getProperties();
+            ClientConfiguration clientCfg = WebClient.getConfig(targetClient);
+            
+            clientCfg.getRequestContext().putAll(configProps);
+            clientCfg.getRequestContext().put(Client.class.getName(), ClientImpl.this);
+            clientCfg.getRequestContext().put(Configuration.class.getName(), 
                                                                       getConfiguration());
             // TLS
             TLSClientParameters tlsParams = secConfig.getTlsClientParams();
             if (tlsParams.getSSLSocketFactory() != null 
                 || tlsParams.getTrustManagers() != null) {
-                WebClient.getConfig(targetClient).getHttpConduit().setTlsClientParameters(tlsParams);
+                clientCfg.getHttpConduit().setTlsClientParameters(tlsParams);
+            }
+            Long connTimeOutValue = getLongValue(configProps.get(HTTP_CONNECTION_TIMEOUT_PROP));
+            if (connTimeOutValue != null) {
+                clientCfg.getHttpConduit().getClient().setConnectionTimeout(connTimeOutValue);
+            }
+            Long recTimeOutValue = getLongValue(configProps.get(HTTP_RECEIVE_TIMEOUT_PROP));
+            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;
+        }
         private void initTargetClientIfNeeded() {
             URI uri = uriBuilder.build();
             if (targetClient == null) {


Mime
View raw message