hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1181130 - in /httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http: conn/ssl/SSLSocketFactory.java impl/client/SystemDefaultHttpClient.java impl/conn/SchemeRegistryFactory.java
Date Mon, 10 Oct 2011 18:46:08 GMT
Author: olegk
Date: Mon Oct 10 18:46:08 2011
New Revision: 1181130

URL: http://svn.apache.org/viewvc?rev=1181130&view=rev
Log:
HTTPCLIENT-1128: SystemDefaultHttpClient to take http.keepAlive and http.maxConnections system
properties into account

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultHttpClient.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SchemeRegistryFactory.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java?rev=1181130&r1=1181129&r2=1181130&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
Mon Oct 10 18:46:08 2011
@@ -179,6 +179,22 @@ public class SSLSocketFactory implements
      * <a href="http://download.oracle.com/javase/1,5.0/docs/guide/security/jsse/JSSERefGuide.html">
      * "JavaTM Secure Socket Extension (JSSE) Reference Guide for the JavaTM 2 Platform
      * Standard Edition 5</a>
+     * <p>
+     * The following system properties are taken into account by this method:
+     * <ul>
+     *  <li>ssl.TrustManagerFactory.algorithm</li>
+     *  <li>javax.net.ssl.trustStoreType</li>
+     *  <li>javax.net.ssl.trustStore</li>
+     *  <li>javax.net.ssl.trustStoreProvider</li>
+     *  <li>javax.net.ssl.trustStorePassword</li>
+     *  <li>java.home</li>
+     *  <li>ssl.KeyManagerFactory.algorithm</li>
+     *  <li>javax.net.ssl.keyStoreType</li>
+     *  <li>javax.net.ssl.keyStore</li>
+     *  <li>javax.net.ssl.keyStoreProvider</li>
+     *  <li>javax.net.ssl.keyStorePassword</li>
+     * </ul>
+     * <p>
      *
      * @return the system SSL socket factory
      */

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultHttpClient.java?rev=1181130&r1=1181129&r2=1181130&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultHttpClient.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultHttpClient.java
Mon Oct 10 18:46:08 2011
@@ -29,9 +29,12 @@ package org.apache.http.impl.client;
 
 import java.net.ProxySelector;
 
+import org.apache.http.ConnectionReuseStrategy;
 import org.apache.http.annotation.ThreadSafe;
 import org.apache.http.conn.ClientConnectionManager;
 import org.apache.http.conn.routing.HttpRoutePlanner;
+import org.apache.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.http.impl.NoConnectionReuseStrategy;
 import org.apache.http.impl.conn.PoolingClientConnectionManager;
 import org.apache.http.impl.conn.ProxySelectorRoutePlanner;
 import org.apache.http.impl.conn.SchemeRegistryFactory;
@@ -40,6 +43,27 @@ import org.apache.http.params.HttpParams
 /**
  * An extension of {@link DefaultHttpClient} pre-configured using system properties.
  * <p>
+ * The following system properties are taken into account by this class:
+ * <ul>
+ *  <li>ssl.TrustManagerFactory.algorithm</li>
+ *  <li>javax.net.ssl.trustStoreType</li>
+ *  <li>javax.net.ssl.trustStore</li>
+ *  <li>javax.net.ssl.trustStoreProvider</li>
+ *  <li>javax.net.ssl.trustStorePassword</li>
+ *  <li>java.home</li>
+ *  <li>ssl.KeyManagerFactory.algorithm</li>
+ *  <li>javax.net.ssl.keyStoreType</li>
+ *  <li>javax.net.ssl.keyStore</li>
+ *  <li>javax.net.ssl.keyStoreProvider</li>
+ *  <li>javax.net.ssl.keyStorePassword</li>
+ *  <li>http.proxyHost</li>
+ *  <li>http.proxyPort</li>
+ *  <li>http.nonProxyHosts</li>
+ *  <li>http.keepAlive</li>
+ *  <li>http.maxConnections</li>
+ * </ul>
+ * <p>
+ * <p>
  * The following parameters can be used to customize the behavior of this
  * class:
  * <ul>
@@ -74,6 +98,7 @@ import org.apache.http.params.HttpParams
  *  <li>{@link org.apache.http.client.params.ClientPNames#DEFAULT_HEADERS}</li>
  *  <li>{@link org.apache.http.client.params.ClientPNames#CONN_MANAGER_TIMEOUT}</li>
  * </ul>
+ * </p>
  *
  * @since 4.2
  */
@@ -90,7 +115,16 @@ public class SystemDefaultHttpClient ext
 
     @Override
     protected ClientConnectionManager createClientConnectionManager() {
-        return new PoolingClientConnectionManager(SchemeRegistryFactory.createSystemDefault());
+        PoolingClientConnectionManager connmgr = new PoolingClientConnectionManager(
+                SchemeRegistryFactory.createSystemDefault());
+        String s = System.getProperty("http.keepAlive");
+        if ("true".equalsIgnoreCase(s)) {
+            s = System.getProperty("http.maxConnections", "5");
+            int max = Integer.parseInt(s);
+            connmgr.setDefaultMaxPerRoute(max);
+            connmgr.setMaxTotal(2 * max);
+        }
+        return connmgr;
     }
 
     @Override
@@ -99,4 +133,14 @@ public class SystemDefaultHttpClient ext
                 ProxySelector.getDefault());
     }
 
+    @Override
+    protected ConnectionReuseStrategy createConnectionReuseStrategy() {
+        String s = System.getProperty("http.keepAlive");
+        if ("true".equalsIgnoreCase(s)) {
+            return new DefaultConnectionReuseStrategy();
+        } else {
+            return new NoConnectionReuseStrategy();
+        }
+    }
+
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SchemeRegistryFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SchemeRegistryFactory.java?rev=1181130&r1=1181129&r2=1181130&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SchemeRegistryFactory.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SchemeRegistryFactory.java
Mon Oct 10 18:46:08 2011
@@ -56,6 +56,22 @@ public final class SchemeRegistryFactory
      * <a href="http://download.oracle.com/javase/1,5.0/docs/guide/security/jsse/JSSERefGuide.html">
      * "JavaTM Secure Socket Extension (JSSE) Reference Guide for the JavaTM 2 Platform
      * Standard Edition 5</a>
+     * <p>
+     * The following system properties are taken into account by this method:
+     * <ul>
+     *  <li>ssl.TrustManagerFactory.algorithm</li>
+     *  <li>javax.net.ssl.trustStoreType</li>
+     *  <li>javax.net.ssl.trustStore</li>
+     *  <li>javax.net.ssl.trustStoreProvider</li>
+     *  <li>javax.net.ssl.trustStorePassword</li>
+     *  <li>java.home</li>
+     *  <li>ssl.KeyManagerFactory.algorithm</li>
+     *  <li>javax.net.ssl.keyStoreType</li>
+     *  <li>javax.net.ssl.keyStore</li>
+     *  <li>javax.net.ssl.keyStoreProvider</li>
+     *  <li>javax.net.ssl.keyStorePassword</li>
+     * </ul>
+     * <p>
      *
      * @since 4.2
      */



Mime
View raw message