hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1562812 - in /httpcomponents/httpclient/trunk: ./ httpclient/src/main/java/org/apache/http/conn/ httpclient/src/main/java/org/apache/http/impl/conn/ httpclient/src/test/java/org/apache/http/impl/conn/
Date Thu, 30 Jan 2014 13:27:12 GMT
Author: olegk
Date: Thu Jan 30 13:27:12 2014
New Revision: 1562812

URL: http://svn.apache.org/r1562812
Log:
HTTPCLIENT-1454: Make connection operator APIs public.
Contributed by Tamas Cservenak <tamas at cservenak.net>

Added:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionOperator.java
  (with props)
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java
  (contents, props changed)
      - copied, changed from r1561333, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java
Removed:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java
Modified:
    httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java

Modified: httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/RELEASE_NOTES.txt?rev=1562812&r1=1562811&r2=1562812&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpclient/trunk/RELEASE_NOTES.txt Thu Jan 30 13:27:12 2014
@@ -1,3 +1,13 @@
+Changes for 4.4-alpha1
+-------------------
+
+Changelog:
+-------------------
+
+* [HTTPCLIENT-1454] Make connection operator APIs public.
+  Contributed by Tamas Cservenak <tamas at cservenak.net>
+
+
 Release 4.3.2
 -------------------
 

Added: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionOperator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionOperator.java?rev=1562812&view=auto
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionOperator.java
(added)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionOperator.java
Thu Jan 30 13:27:12 2014
@@ -0,0 +1,61 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.conn;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+
+import org.apache.http.HttpHost;
+import org.apache.http.config.SocketConfig;
+import org.apache.http.protocol.HttpContext;
+
+/**
+ * Connection operator that performs connection connect and upgrade operations. Usually,
components
+ * participating in these operations are registry of {@link org.apache.http.conn.socket.ConnectionSocketFactory},
+ * {@link SchemePortResolver} and {@link DnsResolver}. In general, HTTP client user should
not
+ * provide implementations of this interface, as HttpClient will use the default one that
covers
+ * most of the cases needed for majority of users.
+ *
+ * @since 4.4
+ */
+public interface HttpClientConnectionOperator {
+
+    void connect(
+            ManagedHttpClientConnection conn,
+            HttpHost host,
+            InetSocketAddress localAddress,
+            int connectTimeout,
+            SocketConfig socketConfig,
+            HttpContext context) throws IOException;
+
+    void upgrade(
+            ManagedHttpClientConnection conn,
+            HttpHost host,
+            HttpContext context) throws IOException;
+
+}

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionOperator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionOperator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionOperator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java?rev=1562812&r1=1562811&r2=1562812&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
Thu Jan 30 13:27:12 2014
@@ -47,6 +47,7 @@ import org.apache.http.config.SocketConf
 import org.apache.http.conn.ConnectionRequest;
 import org.apache.http.conn.DnsResolver;
 import org.apache.http.conn.HttpClientConnectionManager;
+import org.apache.http.conn.HttpClientConnectionOperator;
 import org.apache.http.conn.HttpConnectionFactory;
 import org.apache.http.conn.SchemePortResolver;
 import org.apache.http.conn.ManagedHttpClientConnection;
@@ -118,13 +119,24 @@ public class BasicHttpClientConnectionMa
     }
 
     public BasicHttpClientConnectionManager(
-            final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
-            final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
-            final SchemePortResolver schemePortResolver,
-            final DnsResolver dnsResolver) {
+        final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
+        final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
+        final SchemePortResolver schemePortResolver,
+        final DnsResolver dnsResolver) {
+      this(
+          new DefaultHttpClientConnectionOperator(socketFactoryRegistry, schemePortResolver,
dnsResolver),
+          connFactory
+      );
+    }
+
+    /**
+     * @since 4.4
+     */
+    public BasicHttpClientConnectionManager(
+            final HttpClientConnectionOperator httpClientConnectionOperator,
+            final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory)
{
         super();
-        this.connectionOperator = new HttpClientConnectionOperator(
-                socketFactoryRegistry, schemePortResolver, dnsResolver);
+        this.connectionOperator = Args.notNull(httpClientConnectionOperator, "Connection
operator");
         this.connFactory = connFactory != null ? connFactory : ManagedHttpClientConnectionFactory.INSTANCE;
         this.expiry = Long.MAX_VALUE;
         this.socketConfig = SocketConfig.DEFAULT;

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java
(from r1561333, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java&r1=1561333&r2=1562812&rev=1562812&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java
Thu Jan 30 13:27:12 2014
@@ -43,6 +43,7 @@ import org.apache.http.config.SocketConf
 import org.apache.http.conn.ConnectTimeoutException;
 import org.apache.http.conn.DnsResolver;
 import org.apache.http.conn.HttpClientConnectionManager;
+import org.apache.http.conn.HttpClientConnectionOperator;
 import org.apache.http.conn.HttpHostConnectException;
 import org.apache.http.conn.ManagedHttpClientConnection;
 import org.apache.http.conn.SchemePortResolver;
@@ -52,8 +53,15 @@ import org.apache.http.conn.socket.Layer
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.util.Args;
 
+/**
+ * Default implementation of {@link HttpClientConnectionOperator} used as default in Http
client,
+ * when no instance provided by user to {@link BasicHttpClientConnectionManager} or {@link
+ * PoolingHttpClientConnectionManager} constructor.
+ *
+ * @since 4.4
+ */
 @Immutable
-class HttpClientConnectionOperator {
+public class DefaultHttpClientConnectionOperator implements HttpClientConnectionOperator
{
 
     static final String SOCKET_FACTORY_REGISTRY = "http.socket-factory-registry";
 
@@ -63,7 +71,7 @@ class HttpClientConnectionOperator {
     private final SchemePortResolver schemePortResolver;
     private final DnsResolver dnsResolver;
 
-    HttpClientConnectionOperator(
+    public DefaultHttpClientConnectionOperator(
             final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
             final SchemePortResolver schemePortResolver,
             final DnsResolver dnsResolver) {
@@ -86,6 +94,7 @@ class HttpClientConnectionOperator {
         return reg;
     }
 
+    @Override
     public void connect(
             final ManagedHttpClientConnection conn,
             final HttpHost host,
@@ -146,6 +155,7 @@ class HttpClientConnectionOperator {
         }
     }
 
+    @Override
     public void upgrade(
             final ManagedHttpClientConnection conn,
             final HttpHost host,

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java?rev=1562812&r1=1562811&r2=1562812&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
Thu Jan 30 13:27:12 2014
@@ -50,6 +50,7 @@ import org.apache.http.conn.ConnectionPo
 import org.apache.http.conn.ConnectionRequest;
 import org.apache.http.conn.DnsResolver;
 import org.apache.http.conn.HttpClientConnectionManager;
+import org.apache.http.conn.HttpClientConnectionOperator;
 import org.apache.http.conn.HttpConnectionFactory;
 import org.apache.http.conn.SchemePortResolver;
 import org.apache.http.conn.ManagedHttpClientConnection;
@@ -142,14 +143,30 @@ public class PoolingHttpClientConnection
             final SchemePortResolver schemePortResolver,
             final DnsResolver dnsResolver,
             final long timeToLive, final TimeUnit tunit) {
-        super();
-        this.configData = new ConfigData();
-        this.pool = new CPool(
-                new InternalConnectionFactory(this.configData, connFactory), 2, 20, timeToLive,
tunit);
-        this.connectionOperator = new HttpClientConnectionOperator(
-                socketFactoryRegistry, schemePortResolver, dnsResolver);
+        this(
+            new DefaultHttpClientConnectionOperator(socketFactoryRegistry, schemePortResolver,
dnsResolver),
+            connFactory,
+            timeToLive, tunit
+        );
+    }
+
+    /**
+     * @since 4.4
+     */
+    public PoolingHttpClientConnectionManager(
+        final HttpClientConnectionOperator httpClientConnectionOperator,
+        final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
+        final long timeToLive, final TimeUnit tunit) {
+      super();
+      this.configData = new ConfigData();
+      this.pool = new CPool(
+          new InternalConnectionFactory(this.configData, connFactory), 2, 20, timeToLive,
tunit);
+      this.connectionOperator = Args.notNull(httpClientConnectionOperator, "HttpClientConnectionOperator");
     }
 
+    /**
+     * Visible for test.
+     */
     PoolingHttpClientConnectionManager(
             final CPool pool,
             final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
@@ -158,7 +175,7 @@ public class PoolingHttpClientConnection
         super();
         this.configData = new ConfigData();
         this.pool = pool;
-        this.connectionOperator = new HttpClientConnectionOperator(
+        this.connectionOperator = new DefaultHttpClientConnectionOperator(
                 socketFactoryRegistry, schemePortResolver, dnsResolver);
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java?rev=1562812&r1=1562811&r2=1562812&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java
Thu Jan 30 13:27:12 2014
@@ -59,7 +59,7 @@ public class TestHttpClientConnectionOpe
     private Lookup<ConnectionSocketFactory> socketFactoryRegistry;
     private SchemePortResolver schemePortResolver;
     private DnsResolver dnsResolver;
-    private HttpClientConnectionOperator connectionOperator;
+    private DefaultHttpClientConnectionOperator connectionOperator;
 
     @SuppressWarnings("unchecked")
     @Before
@@ -71,7 +71,7 @@ public class TestHttpClientConnectionOpe
         socketFactoryRegistry = Mockito.mock(Lookup.class);
         schemePortResolver = Mockito.mock(SchemePortResolver.class);
         dnsResolver = Mockito.mock(DnsResolver.class);
-        connectionOperator = new HttpClientConnectionOperator(
+        connectionOperator = new DefaultHttpClientConnectionOperator(
                 socketFactoryRegistry, schemePortResolver, dnsResolver);
     }
 



Mime
View raw message