You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2016/05/15 13:03:10 UTC

[5/6] jena git commit: Preparation for using httpClient new API.

Preparation for using httpClient new API.

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

Branch: refs/heads/master
Commit: 0f46e91893bff63e9b62cc68cdd97b28d9ed5585
Parents: 237de15
Author: Andy Seaborne <an...@apache.org>
Authored: Sun May 15 14:01:54 2016 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sun May 15 14:01:54 2016 +0100

----------------------------------------------------------------------
 .../java/org/apache/jena/riot/web/HttpOp.java   | 21 ++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/0f46e918/jena-arq/src/main/java/org/apache/jena/riot/web/HttpOp.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/web/HttpOp.java b/jena-arq/src/main/java/org/apache/jena/riot/web/HttpOp.java
index 32a9224..3c64815 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/web/HttpOp.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/web/HttpOp.java
@@ -38,6 +38,7 @@ import org.apache.http.entity.ContentType ;
 import org.apache.http.entity.InputStreamEntity ;
 import org.apache.http.entity.StringEntity ;
 import org.apache.http.impl.client.AbstractHttpClient ;
+import org.apache.http.impl.client.HttpClientBuilder ;
 import org.apache.http.impl.client.SystemDefaultHttpClient ;
 import org.apache.http.impl.conn.PoolingClientConnectionManager ;
 import org.apache.http.impl.conn.SchemeRegistryFactory ;
@@ -268,10 +269,26 @@ public class HttpOp {
         useDefaultClientWithAuthentication = useWithAuth;
     }
 
+    public static HttpClient createPoolingHttpClient() {
+        String s = System.getProperty("http.maxConnections", "5");
+        int max = Integer.parseInt(s);
+        return HttpClientBuilder.create()
+            .setMaxConnPerRoute(max)
+            .setMaxConnTotal(2*max)
+            .build() ;
+    }
+    
+//    /** @deprecated Use {@link #createPoolingHttpClient()} */
+//    @Deprecated
+//    public static HttpClient createCachingHttpClient() {
+//        return createPoolingHttpClient() ; 
+//    }
+    
     /**
      * Create an HttpClient that performs connection pooling. This can be used
      * with {@link #setDefaultHttpClient} or provided in the HttpOp calls.
      */
+    @SuppressWarnings("deprecation")
     public static HttpClient createCachingHttpClient() {
         return new SystemDefaultHttpClient() {
             /**
@@ -280,8 +297,8 @@ public class HttpOp {
              */
             @Override
             protected ClientConnectionManager createClientConnectionManager() {
-                PoolingClientConnectionManager connmgr = new PoolingClientConnectionManager(
-                        SchemeRegistryFactory.createSystemDefault());
+                PoolingClientConnectionManager connmgr = 
+                    new PoolingClientConnectionManager(SchemeRegistryFactory.createSystemDefault());
                 String s = System.getProperty("http.maxConnections", "5");
                 int max = Integer.parseInt(s);
                 connmgr.setDefaultMaxPerRoute(max);