hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1405507 [1/3] - in /httpcomponents/httpclient/trunk: ./ fluent-hc/src/main/java/org/apache/http/client/fluent/ httpclient/src/examples/org/apache/http/examples/conn/ httpclient/src/main/java/org/apache/http/conn/ httpclient/src/main/java/o...
Date Sun, 04 Nov 2012 07:37:52 GMT
Author: olegk
Date: Sun Nov  4 07:37:50 2012
New Revision: 1405507

URL: http://svn.apache.org/viewvc?rev=1405507&view=rev
Log:
Connection management API redesign: deprecated ClientConnectionManager, ManagedClientConnection, OperatedClientConnection and ClientConnectionOperator in favor of a simpler HttpClientConnectionManager interface. The new API has a much smaller footprint and no longer supports the concept of managed or operated connections. Internal connection mangement logic is no longer exposed to the consumer

Added:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ConnectionRequest.java
      - copied, changed from r1398094, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionRequest.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java
      - copied, changed from r1398094, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManager.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpConnectionFactory.java   (with props)
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/exec/ConnectionReleaseTriggerImpl.java   (with props)
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java   (with props)
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java
      - copied, changed from r1398094, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpConnPool.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java
      - copied, changed from r1398094, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpPoolEntry.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java   (with props)
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionFactory.java
      - copied, changed from r1398094, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SystemDefaultDnsResolver.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionManagerBase.java   (with props)
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java   (with props)
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java   (with props)
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java   (contents, props changed)
      - copied, changed from r1398094, httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingConnManager.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestIdleConnectionEviction.java   (contents, props changed)
      - copied, changed from r1398094, httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestIdleConnectionEviction.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicHttpClientConnectionManager.java   (with props)
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionManagerBase.java   (with props)
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java   (with props)
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingHttpClientConnectionManager.java   (contents, props changed)
      - copied, changed from r1398094, httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingConnManagerNoServer.java
Removed:
    httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/conn/OperatorConnectDirect.java
    httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/conn/OperatorConnectProxy.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/RequestDirectorAdaptor.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/params/TestRouteParams.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/ExecReqThread.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicConnManager.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestIdleConnectionEviction.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingConnManager.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingConnManagerNoServer.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/AwaitThread.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/GetConnThread.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestConnPoolByRoute.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestWaitingThread.java
Modified:
    httpcomponents/httpclient/trunk/.gitignore
    httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManager.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManagerFactory.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionOperator.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionRequest.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpRoutedConnection.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ManagedClientConnection.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/OperatedClientConnection.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/exec/HttpResponseWrapper.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/exec/MainClientExec.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicClientConnectionManager.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpConnPool.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpPoolEntry.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedClientConnectionImpl.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingClientConnectionManager.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SystemDefaultDnsResolver.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionReuse.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestAutoRetryHttpClient.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRequestRetryHandler.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionAutoRelease.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestContentCodings.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestStatefulConnManagement.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultClientConnectOperator.java

Modified: httpcomponents/httpclient/trunk/.gitignore
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/.gitignore?rev=1405507&r1=1405506&r2=1405507&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/.gitignore (original)
+++ httpcomponents/httpclient/trunk/.gitignore Sun Nov  4 07:37:50 2012
@@ -1,3 +1,4 @@
+bin
 .classpath
 .project
 .settings

Modified: httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java?rev=1405507&r1=1405506&r2=1405507&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java (original)
+++ httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java Sun Nov  4 07:37:50 2012
@@ -55,18 +55,18 @@ import org.apache.http.impl.auth.BasicSc
 import org.apache.http.impl.client.BasicAuthCache;
 import org.apache.http.impl.client.BasicCredentialsProvider;
 import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.conn.PoolingClientConnectionManager;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
 import org.apache.http.protocol.BasicHttpContext;
 
 /**
  * An Executor for fluent requests
  * <p/>
- * A {@link PoolingClientConnectionManager} with maximum 100 connections per route and
+ * A {@link PoolingHttpClientConnectionManager} with maximum 100 connections per route and
  * a total maximum of 200 connections is used internally.
  */
 public class Executor {
 
-    final static PoolingClientConnectionManager CONNMGR;
+    final static PoolingHttpClientConnectionManager CONNMGR;
     final static HttpClient CLIENT;
 
     static {
@@ -90,7 +90,7 @@ public class Executor {
         if (ssl != null) {
             schemeRegistry.register(new Scheme("https", 443, ssl));
         }
-        CONNMGR = new PoolingClientConnectionManager(schemeRegistry);
+        CONNMGR = new PoolingHttpClientConnectionManager(schemeRegistry);
         CONNMGR.setDefaultMaxPerRoute(100);
         CONNMGR.setMaxTotal(200);
         CLIENT = new HttpClientBuilder().setConnectionManager(CONNMGR).build();

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManager.java?rev=1405507&r1=1405506&r2=1405507&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManager.java Sun Nov  4 07:37:50 2012
@@ -44,7 +44,10 @@ import org.apache.http.conn.scheme.Schem
  * from multiple threads.
  *
  * @since 4.0
+ *
+ * @deprecated (4.3) replaced by {@link HttpClientConnectionManager}.
  */
+@Deprecated
 public interface ClientConnectionManager {
 
     /**

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManagerFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManagerFactory.java?rev=1405507&r1=1405506&r2=1405507&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManagerFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManagerFactory.java Sun Nov  4 07:37:50 2012
@@ -33,9 +33,11 @@ import org.apache.http.params.HttpParams
 /**
  * A factory for creating new {@link ClientConnectionManager} instances.
  *
- *
  * @since 4.0
+ *
+ * @deprecated (4.3) replaced by {@link HttpClientConnectionManager}.
  */
+@Deprecated
 public interface ClientConnectionManagerFactory {
 
     ClientConnectionManager newInstance(

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionOperator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionOperator.java?rev=1405507&r1=1405506&r2=1405507&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionOperator.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionOperator.java Sun Nov  4 07:37:50 2012
@@ -51,7 +51,10 @@ import org.apache.http.protocol.HttpCont
  * from multiple threads.
  *
  * @since 4.0
+ *
+ * @deprecated (4.3) replaced by {@link HttpClientConnectionManager}.
  */
+@Deprecated
 public interface ClientConnectionOperator {
 
     /**

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionRequest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionRequest.java?rev=1405507&r1=1405506&r2=1405507&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionRequest.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionRequest.java Sun Nov  4 07:37:50 2012
@@ -33,7 +33,10 @@ import java.util.concurrent.TimeUnit;
  * Encapsulates a request for a {@link ManagedClientConnection}.
  *
  * @since 4.0
+ *
+ * @deprecated (4.3) replaced by {@link ConnectionRequest}.
  */
+@Deprecated
 public interface ClientConnectionRequest {
 
     /**

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ConnectionRequest.java (from r1398094, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionRequest.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ConnectionRequest.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ConnectionRequest.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionRequest.java&r1=1398094&r2=1405507&rev=1405507&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionRequest.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ConnectionRequest.java Sun Nov  4 07:37:50 2012
@@ -29,12 +29,15 @@ package org.apache.http.conn;
 
 import java.util.concurrent.TimeUnit;
 
+import org.apache.http.HttpClientConnection;
+import org.apache.http.concurrent.Cancellable;
+
 /**
- * Encapsulates a request for a {@link ManagedClientConnection}.
+ * Encapsulates a request for a {@link HttpClientConnection}.
  *
- * @since 4.0
+ * @since 4.3
  */
-public interface ClientConnectionRequest {
+public interface ConnectionRequest extends Cancellable {
 
     /**
      * Obtains a connection within a given time.
@@ -43,7 +46,7 @@ public interface ClientConnectionRequest
      * {@link ClientConnectionManager#shutdown() shut down}.
      * Timeouts are handled with millisecond precision.
      *
-     * If {@link #abortRequest()} is called while this is blocking or
+     * If {@link #cancel()} is called while this is blocking or
      * before this began, an {@link InterruptedException} will
      * be thrown.
      *
@@ -59,13 +62,7 @@ public interface ClientConnectionRequest
      * @throws InterruptedException
      *         if the calling thread is interrupted while waiting
      */
-    ManagedClientConnection getConnection(long timeout, TimeUnit tunit)
+    HttpClientConnection get(long timeout, TimeUnit tunit)
         throws InterruptedException, ConnectionPoolTimeoutException;
 
-    /**
-     * Aborts the call to {@link #getConnection(long, TimeUnit)},
-     * causing it to throw an {@link InterruptedException}.
-     */
-    void abortRequest();
-
 }

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java (from r1398094, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManager.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManager.java&r1=1398094&r2=1405507&rev=1405507&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java Sun Nov  4 07:37:50 2012
@@ -1,21 +1,20 @@
 /*
  * ====================================================================
- * 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.
+ *
+ *  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
@@ -27,39 +26,42 @@
 
 package org.apache.http.conn;
 
+import java.io.IOException;
+import java.net.InetAddress;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.http.HttpClientConnection;
+import org.apache.http.HttpHost;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.params.HttpParams;
+import org.apache.http.protocol.HttpContext;
 
 /**
- * Management interface for {@link ManagedClientConnection client connections}.
+ * Represents a manager of persistent client connections.
+ * <p/>
  * The purpose of an HTTP connection manager is to serve as a factory for new
  * HTTP connections, manage persistent connections and synchronize access to
  * persistent connections making sure that only one thread of execution can
  * have access to a connection at a time.
- * <p>
+ * <p/>
  * Implementations of this interface must be thread-safe. Access to shared
  * data must be synchronized as methods of this interface may be executed
  * from multiple threads.
  *
- * @since 4.0
+ * @since 4.3
  */
-public interface ClientConnectionManager {
+public interface HttpClientConnectionManager {
 
-    /**
-     * Obtains the scheme registry used by this manager.
-     *
-     * @return  the scheme registry, never <code>null</code>
-     */
     SchemeRegistry getSchemeRegistry();
 
     /**
      * Returns a new {@link ClientConnectionRequest}, from which a
-     * {@link ManagedClientConnection} can be obtained or the request can be
+     * {@link HttpClientConnection} can be obtained or the request can be
      * aborted.
      */
-    ClientConnectionRequest requestConnection(HttpRoute route, Object state);
+    ConnectionRequest requestConnection(
+            HttpRoute route, Object state);
 
     /**
      * Releases a connection for use by others.
@@ -77,7 +79,16 @@ public interface ClientConnectionManager
      *
      * @see #closeExpiredConnections()
      */
-    void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit);
+    void releaseConnection(
+            HttpClientConnection conn, Object newState, long validDuration, TimeUnit timeUnit);
+
+    void connect(
+            HttpClientConnection conn, HttpHost host, InetAddress localAddress,
+            HttpContext context, HttpParams params) throws IOException;
+
+    void upgrade(
+            HttpClientConnection conn, HttpHost host,
+            HttpContext context,  HttpParams params) throws IOException;
 
     /**
      * Closes idle connections in the pool.

Added: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpConnectionFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpConnectionFactory.java?rev=1405507&view=auto
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpConnectionFactory.java (added)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpConnectionFactory.java Sun Nov  4 07:37:50 2012
@@ -0,0 +1,40 @@
+/*
+ * ====================================================================
+ *
+ *  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 org.apache.http.HttpConnection;
+
+/**
+ * Generic {@link HttpConnection} factory.
+ *
+ * @since 4.3
+ */
+public interface HttpConnectionFactory<T extends HttpConnection> {
+
+    T create();
+
+}

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

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

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

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpRoutedConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpRoutedConnection.java?rev=1405507&r1=1405506&r2=1405507&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpRoutedConnection.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpRoutedConnection.java Sun Nov  4 07:37:50 2012
@@ -37,7 +37,7 @@ import org.apache.http.conn.routing.Http
  *
  * @since 4.1
  *
- * @deprecated (4.3) no longer used
+ * @deprecated (4.3) replaced by {@link HttpClientConnectionManager}.
  */
 @Deprecated
 public interface HttpRoutedConnection extends HttpInetConnection {

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ManagedClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ManagedClientConnection.java?rev=1405507&r1=1405506&r2=1405507&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ManagedClientConnection.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ManagedClientConnection.java Sun Nov  4 07:37:50 2012
@@ -44,8 +44,10 @@ import org.apache.http.conn.routing.Http
  * Instances are typically obtained from a connection manager.
  *
  * @since 4.0
+ *
+ * @deprecated (4.3) replaced by {@link HttpClientConnectionManager}.
  */
-@SuppressWarnings("deprecation")
+@Deprecated
 public interface ManagedClientConnection extends
     HttpClientConnection, HttpRoutedConnection, HttpSSLConnection, ConnectionReleaseTrigger {
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/OperatedClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/OperatedClientConnection.java?rev=1405507&r1=1405506&r2=1405507&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/OperatedClientConnection.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/OperatedClientConnection.java Sun Nov  4 07:37:50 2012
@@ -41,7 +41,10 @@ import org.apache.http.params.HttpParams
  * {@link ClientConnectionOperator operator}.
  *
  * @since 4.0
+ *
+ * @deprecated (4.3) replaced by {@link HttpClientConnectionManager}.
  */
+@Deprecated
 public interface OperatedClientConnection extends HttpClientConnection, HttpInetConnection {
 
     /**

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java?rev=1405507&r1=1405506&r2=1405507&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java Sun Nov  4 07:37:50 2012
@@ -148,11 +148,6 @@ public class PlainSocketFactory implemen
         if (sock == null) {
             throw new IllegalArgumentException("Socket may not be null.");
         }
-        // This check is performed last since it calls a method implemented
-        // by the argument object. getClass() is final in java.lang.Object.
-        if (sock.isClosed()) {
-            throw new IllegalArgumentException("Socket is closed.");
-        }
         return false;
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java?rev=1405507&r1=1405506&r2=1405507&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java Sun Nov  4 07:37:50 2012
@@ -940,7 +940,8 @@ public abstract class AbstractHttpClient
             final AuthenticationStrategy proxyAuthStrategy,
             final UserTokenHandler userTokenHandler,
             final HttpParams params) {
-        return new RequestDirectorAdaptor(
+        return new DefaultRequestDirector(
+                log,
                 requestExec,
                 conman,
                 reustrat,

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java?rev=1405507&r1=1405506&r2=1405507&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java Sun Nov  4 07:37:50 2012
@@ -61,8 +61,8 @@ import org.apache.http.client.protocol.R
 import org.apache.http.client.protocol.RequestDefaultHeaders;
 import org.apache.http.client.protocol.ResponseContentEncoding;
 import org.apache.http.client.protocol.ResponseProcessCookies;
-import org.apache.http.conn.ClientConnectionManager;
 import org.apache.http.conn.ConnectionKeepAliveStrategy;
+import org.apache.http.conn.HttpClientConnectionManager;
 import org.apache.http.conn.routing.HttpRoutePlanner;
 import org.apache.http.conn.scheme.Scheme;
 import org.apache.http.conn.scheme.SchemeLayeredSocketFactory;
@@ -83,8 +83,8 @@ import org.apache.http.impl.client.exec.
 import org.apache.http.impl.client.exec.RedirectExec;
 import org.apache.http.impl.client.exec.RetryExec;
 import org.apache.http.impl.client.exec.ServiceUnavailableRetryExec;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
 import org.apache.http.impl.conn.DefaultHttpRoutePlanner;
-import org.apache.http.impl.conn.PoolingClientConnectionManager;
 import org.apache.http.impl.conn.ProxySelectorRoutePlanner;
 import org.apache.http.impl.conn.SchemeRegistryFactory;
 import org.apache.http.impl.cookie.BestMatchSpecFactory;
@@ -185,7 +185,7 @@ public class HttpClientBuilder {
 
     private HttpRequestExecutor requestExec;
     private SchemeLayeredSocketFactory sslSocketFactory;
-    private ClientConnectionManager connManager;
+    private HttpClientConnectionManager connManager;
     private ConnectionReuseStrategy reuseStrategy;
     private ConnectionKeepAliveStrategy keepAliveStrategy;
     private AuthenticationStrategy targetAuthStrategy;
@@ -240,7 +240,7 @@ public class HttpClientBuilder {
         return this;
     }
 
-    public final HttpClientBuilder setConnectionManager(final ClientConnectionManager connManager) {
+    public final HttpClientBuilder setConnectionManager(final HttpClientConnectionManager connManager) {
         this.connManager = connManager;
         return this;
     }
@@ -438,7 +438,7 @@ public class HttpClientBuilder {
         if (requestExec == null) {
             requestExec = new HttpRequestExecutor();
         }
-        ClientConnectionManager connManager = this.connManager;
+        HttpClientConnectionManager connManager = this.connManager;
         if (connManager == null) {
             SchemeRegistry schemeRegistry = systemProperties ?
                     SchemeRegistryFactory.createSystemDefault() :
@@ -446,7 +446,7 @@ public class HttpClientBuilder {
             if (sslSocketFactory != null) {
                 schemeRegistry.register(new Scheme("https", 443, sslSocketFactory));
             }
-            PoolingClientConnectionManager poolingmgr = new PoolingClientConnectionManager(
+            PoolingHttpClientConnectionManager poolingmgr = new PoolingHttpClientConnectionManager(
                     schemeRegistry);
             if (systemProperties) {
                 String s = System.getProperty("http.keepAlive");

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java?rev=1405507&r1=1405506&r2=1405507&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java Sun Nov  4 07:37:50 2012
@@ -28,6 +28,7 @@
 package org.apache.http.impl.client;
 
 import java.io.IOException;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.http.HttpException;
 import org.apache.http.HttpHost;
@@ -43,8 +44,12 @@ import org.apache.http.client.methods.Ht
 import org.apache.http.client.params.ClientPNames;
 import org.apache.http.client.protocol.ClientContext;
 import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.ClientConnectionRequest;
+import org.apache.http.conn.ManagedClientConnection;
+import org.apache.http.conn.HttpClientConnectionManager;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.routing.HttpRoutePlanner;
+import org.apache.http.conn.scheme.SchemeRegistry;
 import org.apache.http.cookie.CookieSpecRegistry;
 import org.apache.http.impl.client.exec.ClientExecChain;
 import org.apache.http.impl.client.exec.HttpRequestWrapper;
@@ -61,7 +66,7 @@ import org.apache.http.protocol.HttpCont
 class InternalHttpClient extends AbstractBasicHttpClient {
 
     private final ClientExecChain execChain;
-    private final ClientConnectionManager connManager;
+    private final HttpClientConnectionManager connManager;
     private final HttpRoutePlanner routePlanner;
     private final CookieSpecRegistry cookieSpecRegistry;
     private final AuthSchemeRegistry authSchemeRegistry;
@@ -71,7 +76,7 @@ class InternalHttpClient extends Abstrac
 
     public InternalHttpClient(
             final ClientExecChain execChain,
-            final ClientConnectionManager connManager,
+            final HttpClientConnectionManager connManager,
             final HttpRoutePlanner routePlanner,
             final CookieSpecRegistry cookieSpecRegistry,
             final AuthSchemeRegistry authSchemeRegistry,
@@ -169,7 +174,38 @@ class InternalHttpClient extends Abstrac
     }
 
     public ClientConnectionManager getConnectionManager() {
-        return this.connManager;
+
+        return new ClientConnectionManager() {
+
+            public void shutdown() {
+                connManager.shutdown();
+            }
+
+            public ClientConnectionRequest requestConnection(
+                    HttpRoute route, Object state) {
+                throw new UnsupportedOperationException();
+            }
+
+            public void releaseConnection(
+                    ManagedClientConnection conn,
+                    long validDuration, TimeUnit timeUnit) {
+                throw new UnsupportedOperationException();
+            }
+
+            public SchemeRegistry getSchemeRegistry() {
+                throw new UnsupportedOperationException();
+            }
+
+            public void closeIdleConnections(long idletime, TimeUnit tunit) {
+                connManager.closeIdleConnections(idletime, tunit);
+            }
+
+            public void closeExpiredConnections() {
+                connManager.closeExpiredConnections();
+            }
+
+        };
+
     }
 
 }

Added: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/exec/ConnectionReleaseTriggerImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/exec/ConnectionReleaseTriggerImpl.java?rev=1405507&view=auto
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/exec/ConnectionReleaseTriggerImpl.java (added)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/exec/ConnectionReleaseTriggerImpl.java Sun Nov  4 07:37:50 2012
@@ -0,0 +1,134 @@
+/*
+ * ====================================================================
+ * 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.impl.client.exec;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.logging.Log;
+import org.apache.http.HttpClientConnection;
+import org.apache.http.annotation.ThreadSafe;
+import org.apache.http.concurrent.Cancellable;
+import org.apache.http.conn.ConnectionReleaseTrigger;
+import org.apache.http.conn.HttpClientConnectionManager;
+
+/**
+ * Internal {@link ConnectionReleaseTrigger} implementation.
+ *
+ * @since 4.3
+ */
+@ThreadSafe
+class ConnectionReleaseTriggerImpl implements ConnectionReleaseTrigger, Cancellable {
+
+    private final Log log;
+
+    private final HttpClientConnectionManager manager;
+    private final HttpClientConnection managedConn;
+    private volatile boolean reusable;
+    private volatile Object state;
+    private volatile long validDuration;
+    private volatile TimeUnit tunit;
+
+    private volatile boolean released;
+
+    public ConnectionReleaseTriggerImpl(
+            final Log log,
+            final HttpClientConnectionManager manager,
+            final HttpClientConnection managedConn) {
+        super();
+        this.log = log;
+        this.manager = manager;
+        this.managedConn = managedConn;
+    }
+
+    public boolean isReusable() {
+        return this.reusable;
+    }
+
+    public void markReusable() {
+        this.reusable = true;
+    }
+
+    public void markNonReusable() {
+        this.reusable = false;
+    }
+
+    public void setState(final Object state) {
+        this.state = state;
+    }
+
+    public void setValidFor(final long duration, final TimeUnit tunit) {
+        synchronized (this.managedConn) {
+            this.validDuration = duration;
+            this.tunit = tunit;
+        }
+    }
+
+    public void releaseConnection() {
+        synchronized (this.managedConn) {
+            if (this.released) {
+                return;
+            }
+            this.released = true;
+            this.manager.releaseConnection(this.managedConn,
+                    this.state, this.validDuration, this.tunit);
+        }
+    }
+
+    public void abortConnection() {
+        synchronized (this.managedConn) {
+            if (this.released) {
+                return;
+            }
+            this.released = true;
+            try {
+                this.managedConn.shutdown();
+                log.debug("Connection discarded");
+            } catch (IOException ex) {
+                if (this.log.isDebugEnabled()) {
+                    this.log.debug(ex.getMessage(), ex);
+                }
+            } finally {
+                this.manager.releaseConnection(
+                        this.managedConn, null, 0, TimeUnit.MILLISECONDS);
+            }
+        }
+    }
+
+    public boolean cancel() {
+        boolean alreadyReleased = this.released;
+        log.debug("Cancelling request execution");
+        abortConnection();
+        return !alreadyReleased;
+    }
+
+    public boolean isReleased() {
+        return this.released;
+    }
+
+}

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

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

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

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/exec/HttpResponseWrapper.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/exec/HttpResponseWrapper.java?rev=1405507&r1=1405506&r2=1405507&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/exec/HttpResponseWrapper.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/exec/HttpResponseWrapper.java Sun Nov  4 07:37:50 2012
@@ -44,7 +44,6 @@ import org.apache.http.annotation.NotThr
 import org.apache.http.conn.ConnectionReleaseTrigger;
 import org.apache.http.conn.EofSensorInputStream;
 import org.apache.http.conn.EofSensorWatcher;
-import org.apache.http.conn.ManagedClientConnection;
 import org.apache.http.entity.HttpEntityWrapper;
 import org.apache.http.params.HttpParams;
 import org.apache.http.util.EntityUtils;
@@ -59,15 +58,17 @@ import org.apache.http.util.EntityUtils;
 public class HttpResponseWrapper implements HttpResponse, ConnectionReleaseTrigger, Closeable {
 
     private final HttpResponse original;
+    private final ConnectionReleaseTriggerImpl connReleaseTrigger;
     private HttpEntity entity;
-    private ManagedClientConnection conn;
 
-    private HttpResponseWrapper(final HttpResponse original, final ManagedClientConnection conn) {
+    private HttpResponseWrapper(
+            final HttpResponse original,
+            final ConnectionReleaseTriggerImpl connReleaseTrigger) {
         super();
         this.original = original;
-        this.conn = conn;
+        this.connReleaseTrigger = connReleaseTrigger;
         HttpEntity entity = original.getEntity();
-        if (conn != null && entity != null && entity.isStreaming()) {
+        if (connReleaseTrigger != null && entity != null && entity.isStreaming()) {
             this.entity = new EntityWrapper(entity);
         }
     }
@@ -185,23 +186,21 @@ public class HttpResponseWrapper impleme
     }
 
     private void cleanup() throws IOException {
-        if (this.conn != null) {
-            this.conn.abortConnection();
-            this.conn = null;
+        if (this.connReleaseTrigger != null) {
+            this.connReleaseTrigger.abortConnection();
         }
     }
 
     public void releaseConnection() throws IOException {
-        if (this.conn != null) {
+        if (this.connReleaseTrigger != null) {
             try {
-                if (this.conn.isMarkedReusable()) {
+                if (this.connReleaseTrigger.isReusable()) {
                     HttpEntity entity = this.original.getEntity();
                     if (entity != null) {
                         EntityUtils.consume(entity);
                     }
+                    this.connReleaseTrigger.releaseConnection();
                 }
-                this.conn.releaseConnection();
-                this.conn = null;
             } finally {
                 cleanup();
             }
@@ -258,7 +257,7 @@ public class HttpResponseWrapper impleme
 
         public boolean streamClosed(InputStream wrapped) throws IOException {
             try {
-                boolean open = conn != null && conn.isOpen();
+                boolean open = connReleaseTrigger != null && !connReleaseTrigger.isReleased();
                 // this assumes that closing the stream will
                 // consume the remainder of the response body:
                 try {
@@ -284,8 +283,8 @@ public class HttpResponseWrapper impleme
 
     public static HttpResponseWrapper wrap(
             final HttpResponse response,
-            final ManagedClientConnection conn) {
-        return new HttpResponseWrapper(response, conn);
+            final ConnectionReleaseTriggerImpl connReleaseTrigger) {
+        return new HttpResponseWrapper(response, connReleaseTrigger);
     }
 
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/exec/MainClientExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/exec/MainClientExec.java?rev=1405507&r1=1405506&r2=1405507&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/exec/MainClientExec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/exec/MainClientExec.java Sun Nov  4 07:37:50 2012
@@ -34,6 +34,7 @@ import java.util.concurrent.TimeUnit;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.http.ConnectionReuseStrategy;
+import org.apache.http.HttpClientConnection;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpException;
 import org.apache.http.HttpHost;
@@ -52,15 +53,13 @@ import org.apache.http.client.methods.Ht
 import org.apache.http.client.params.HttpClientParams;
 import org.apache.http.client.protocol.ClientContext;
 import org.apache.http.client.protocol.RequestClientConnControl;
-import org.apache.http.concurrent.Cancellable;
-import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.conn.ClientConnectionRequest;
 import org.apache.http.conn.ConnectionKeepAliveStrategy;
-import org.apache.http.conn.ConnectionReleaseTrigger;
-import org.apache.http.conn.ManagedClientConnection;
+import org.apache.http.conn.ConnectionRequest;
+import org.apache.http.conn.HttpClientConnectionManager;
 import org.apache.http.conn.routing.BasicRouteDirector;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.routing.HttpRouteDirector;
+import org.apache.http.conn.routing.RouteTracker;
 import org.apache.http.conn.scheme.Scheme;
 import org.apache.http.conn.scheme.SchemeRegistry;
 import org.apache.http.entity.BufferedHttpEntity;
@@ -113,7 +112,7 @@ public class MainClientExec implements C
     private final Log log = LogFactory.getLog(getClass());
 
     private final HttpRequestExecutor requestExecutor;
-    private final ClientConnectionManager connManager;
+    private final HttpClientConnectionManager connManager;
     private final ConnectionReuseStrategy reuseStrategy;
     private final ConnectionKeepAliveStrategy keepAliveStrategy;
     private final HttpProcessor proxyHttpProcessor;
@@ -126,7 +125,7 @@ public class MainClientExec implements C
 
     public MainClientExec(
             final HttpRequestExecutor requestExecutor,
-            final ClientConnectionManager connManager,
+            final HttpClientConnectionManager connManager,
             final ConnectionReuseStrategy reuseStrategy,
             final ConnectionKeepAliveStrategy keepAliveStrategy,
             final AuthenticationStrategy targetAuthStrategy,
@@ -196,27 +195,20 @@ public class MainClientExec implements C
 
         Object userToken = context.getAttribute(ClientContext.USER_TOKEN);
 
-        final ClientConnectionRequest connRequest = connManager.requestConnection(route, userToken);
+        final ConnectionRequest connRequest = connManager.requestConnection(route, userToken);
         if (execAware != null) {
             if (execAware.isAborted()) {
-                connRequest.abortRequest();
+                connRequest.cancel();
                 throw new RequestAbortedException("Request aborted");
             } else {
-                execAware.setCancellable(new Cancellable() {
-
-                    public boolean cancel() {
-                        connRequest.abortRequest();
-                        return true;
-                    }
-
-                });
+                execAware.setCancellable(connRequest);
             }
         }
 
-        ManagedClientConnection managedConn;
+        HttpClientConnection managedConn;
         try {
             long timeout = HttpClientParams.getConnectionManagerTimeout(params);
-            managedConn = connRequest.getConnection(timeout, TimeUnit.MILLISECONDS);
+            managedConn = connRequest.get(timeout, TimeUnit.MILLISECONDS);
         } catch(InterruptedException interrupted) {
             throw new RequestAbortedException("Request aborted", interrupted);
         }
@@ -234,28 +226,18 @@ public class MainClientExec implements C
             }
         }
 
-        if (execAware != null) {
-            if (execAware.isAborted()) {
-                managedConn.releaseConnection();
-                throw new RequestAbortedException("Request aborted");
-            } else {
-                final ConnectionReleaseTrigger trigger = managedConn;
-                execAware.setCancellable(new Cancellable() {
-
-                    public boolean cancel() {
-                        try {
-                            trigger.abortConnection();
-                        } catch (IOException ex) {
-                            log.debug("I/O error aborting connection", ex);
-                        }
-                        return true;
-                    }
-
-                });
+        ConnectionReleaseTriggerImpl releaseTrigger = new ConnectionReleaseTriggerImpl(
+                this.log, this.connManager, managedConn);
+        try {
+            if (execAware != null) {
+                if (execAware.isAborted()) {
+                    releaseTrigger.abortConnection();
+                    throw new RequestAbortedException("Request aborted");
+                } else {
+                    execAware.setCancellable(releaseTrigger);
+                }
             }
-        }
 
-        try {
             HttpResponse response = null;
             for (int execCount = 1;; execCount++) {
 
@@ -270,21 +252,19 @@ public class MainClientExec implements C
 
                 if (!managedConn.isOpen()) {
                     this.log.debug("Opening connection " + route);
-                    managedConn.open(route, context, params);
+                    try {
+                        establishRoute(proxyAuthState, managedConn, route, request, context);
+                    } catch (TunnelRefusedException ex) {
+                        if (this.log.isDebugEnabled()) {
+                            this.log.debug(ex.getMessage());
+                        }
+                        response = ex.getResponse();
+                        break;
+                    }
                 } else {
                     managedConn.setSocketTimeout(HttpConnectionParams.getSoTimeout(params));
                 }
 
-                try {
-                    establishRoute(proxyAuthState, managedConn, route, request, context);
-                } catch (TunnelRefusedException ex) {
-                    if (this.log.isDebugEnabled()) {
-                        this.log.debug(ex.getMessage());
-                    }
-                    response = ex.getResponse();
-                    break;
-                }
-
                 if (execAware != null && execAware.isAborted()) {
                     throw new RequestAbortedException("Request aborted");
                 }
@@ -322,15 +302,15 @@ public class MainClientExec implements C
                         }
                         this.log.debug("Connection can be kept alive " + s);
                     }
-                    managedConn.setIdleDuration(duration, TimeUnit.MILLISECONDS);
-                    managedConn.markReusable();
+                    releaseTrigger.setValidFor(duration, TimeUnit.MILLISECONDS);
+                    releaseTrigger.markReusable();
                 } else {
-                    managedConn.unmarkReusable();
+                    releaseTrigger.markNonReusable();
                 }
 
                 if (needAuthentication(
                         targetAuthState, proxyAuthState, route, request, response, context)) {
-                    if (managedConn.isMarkedReusable()) {
+                    if (releaseTrigger.isReusable()) {
                         // Make sure the response body is fully consumed, if present
                         HttpEntity entity = response.getEntity();
                         EntityUtils.consume(entity);
@@ -364,21 +344,17 @@ public class MainClientExec implements C
                 context.setAttribute(ClientContext.USER_TOKEN, userToken);
             }
             if (userToken != null) {
-                managedConn.setState(userToken);
+                releaseTrigger.setState(userToken);
             }
 
             // check for entity, release connection if possible
             HttpEntity entity = response.getEntity();
             if (entity == null || !entity.isStreaming()) {
                 // connection not needed and (assumed to be) in re-usable state
-                try {
-                    managedConn.releaseConnection();
-                } catch(IOException ex) {
-                    this.log.debug("IOException releasing connection", ex);
-                }
+                releaseTrigger.releaseConnection();
                 return HttpResponseWrapper.wrap(response, null);
             } else {
-                return HttpResponseWrapper.wrap(response, managedConn);
+                return HttpResponseWrapper.wrap(response, releaseTrigger);
             }
         } catch (ConnectionShutdownException ex) {
             InterruptedIOException ioex = new InterruptedIOException(
@@ -386,13 +362,13 @@ public class MainClientExec implements C
             ioex.initCause(ex);
             throw ioex;
         } catch (HttpException ex) {
-            abortConnection(managedConn);
+            releaseTrigger.abortConnection();
             throw ex;
         } catch (IOException ex) {
-            abortConnection(managedConn);
+            releaseTrigger.abortConnection();
             throw ex;
         } catch (RuntimeException ex) {
-            abortConnection(managedConn);
+            releaseTrigger.abortConnection();
             throw ex;
         }
     }
@@ -402,27 +378,34 @@ public class MainClientExec implements C
      */
     private void establishRoute(
             final AuthState proxyAuthState,
-            final ManagedClientConnection managedConn,
+            final HttpClientConnection managedConn,
             final HttpRoute route,
             final HttpRequest request,
             final HttpContext context) throws HttpException, IOException {
         HttpParams params = request.getParams();
+        RouteTracker tracker = new RouteTracker(route);
         int step;
         do {
-            HttpRoute fact = managedConn.getRoute();
+            HttpRoute fact = tracker.toRoute();
             step = this.routeDirector.nextStep(route, fact);
 
             switch (step) {
 
             case HttpRouteDirector.CONNECT_TARGET:
+                this.connManager.connect(
+                        managedConn, route.getTargetHost(), route.getLocalAddress(), context, params);
+                tracker.connectTarget(route.isSecure());
+                break;
             case HttpRouteDirector.CONNECT_PROXY:
-                managedConn.open(route, context, params);
+                this.connManager.connect(
+                        managedConn, route.getProxyHost(), route.getLocalAddress(), context, params);
+                HttpHost proxy  = route.getProxyHost();
+                tracker.connectProxy(proxy, false);
                 break;
-
             case HttpRouteDirector.TUNNEL_TARGET: {
                 boolean secure = createTunnelToTarget(proxyAuthState, managedConn, route, request, context);
                 this.log.debug("Tunnel to target created.");
-                managedConn.tunnelTarget(secure, params);
+                tracker.tunnelTarget(secure);
             }   break;
 
             case HttpRouteDirector.TUNNEL_PROXY: {
@@ -433,11 +416,11 @@ public class MainClientExec implements C
                 final int hop = fact.getHopCount()-1; // the hop to establish
                 boolean secure = createTunnelToProxy(route, hop, context);
                 this.log.debug("Tunnel to proxy created.");
-                managedConn.tunnelProxy(route.getHopTarget(hop), secure, params);
+                tracker.tunnelProxy(route.getHopTarget(hop), secure);
             }   break;
 
             case HttpRouteDirector.LAYER_PROTOCOL:
-                managedConn.layerProtocol(context, params);
+                this.connManager.upgrade(managedConn, route.getTargetHost(), context, params);
                 break;
 
             case HttpRouteDirector.UNREACHABLE:
@@ -473,7 +456,7 @@ public class MainClientExec implements C
      */
     private boolean createTunnelToTarget(
             final AuthState proxyAuthState,
-            final ManagedClientConnection managedConn,
+            final HttpClientConnection managedConn,
             final HttpRoute route,
             final HttpRequest request,
             final HttpContext context) throws HttpException, IOException {
@@ -505,7 +488,8 @@ public class MainClientExec implements C
 
         for (;;) {
             if (!managedConn.isOpen()) {
-                managedConn.open(route, context, params);
+                this.connManager.connect(
+                        managedConn, route.getProxyHost(), route.getLocalAddress(), context, params);
             }
 
             connect.removeHeaders(AUTH.PROXY_AUTH_RESP);
@@ -557,8 +541,6 @@ public class MainClientExec implements C
                     response.getStatusLine(), response);
         }
 
-        managedConn.markReusable();
-
         // How to decide on security of the tunnelled connection?
         // The socket factory knows only about the segment to the proxy.
         // Even if that is secure, the hop to the target may be insecure.
@@ -621,21 +603,4 @@ public class MainClientExec implements C
         return false;
     }
 
-    /**
-     * Shuts down the connection.
-     * This method is called from a <code>catch</code> block in
-     * {@link #execute execute} during exception handling.
-     */
-    private void abortConnection(final ManagedClientConnection managedConn) {
-        // we got here as the result of an exception
-        // no response will be returned, release the connection
-        try {
-            managedConn.abortConnection();
-        } catch (IOException ex) {
-            if (this.log.isDebugEnabled()) {
-                this.log.debug(ex.getMessage(), ex);
-            }
-        }
-    }
-
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicClientConnectionManager.java?rev=1405507&r1=1405506&r2=1405507&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicClientConnectionManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicClientConnectionManager.java Sun Nov  4 07:37:50 2012
@@ -59,8 +59,11 @@ import org.apache.http.conn.scheme.Schem
  * {@link PoolingClientConnectionManager}.
  *
  * @since 4.2
+ *
+ * @deprecated (4.3) use {@link BasicHttpClientConnectionManager}.
  */
 @ThreadSafe
+@Deprecated
 public class BasicClientConnectionManager implements ClientConnectionManager {
 
     private final Log log = LogFactory.getLog(getClass());

Added: 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=1405507&view=auto
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java (added)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java Sun Nov  4 07:37:50 2012
@@ -0,0 +1,335 @@
+/*
+ * ====================================================================
+ * 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.impl.conn;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.util.Date;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.HttpClientConnection;
+import org.apache.http.HttpHost;
+import org.apache.http.annotation.GuardedBy;
+import org.apache.http.annotation.ThreadSafe;
+import org.apache.http.conn.ConnectionRequest;
+import org.apache.http.conn.DnsResolver;
+import org.apache.http.conn.HttpClientConnectionManager;
+import org.apache.http.conn.HttpConnectionFactory;
+import org.apache.http.conn.routing.HttpRoute;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.params.HttpParams;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.LangUtils;
+
+/**
+ * A connection manager for a single connection. This connection manager maintains only one active
+ * connection. Even though this class is fully thread-safe it ought to be used by one execution
+ * thread only, as only one thread a time can lease the connection at a time.
+ * <p/>
+ * This connection manager will make an effort to reuse the connection for subsequent requests
+ * with the same {@link HttpRoute route}. It will, however, close the existing connection and
+ * open it for the given route, if the route of the persistent connection does not match that
+ * of the connection request. If the connection has been already been allocated
+ * {@link IllegalStateException} is thrown.
+ * <p/>
+ * This connection manager implementation should be used inside an EJB container instead of
+ * {@link PoolingHttpClientConnectionManager}.
+ *
+ * @since 4.3
+ */
+@ThreadSafe
+public class BasicHttpClientConnectionManager implements HttpClientConnectionManager {
+
+    private final Log log = LogFactory.getLog(getClass());
+
+    private final HttpClientConnectionOperator connectionOperator;
+    private final HttpConnectionFactory<DefaultClientConnection> connFactory;
+
+    @GuardedBy("this")
+    private DefaultClientConnection conn;
+
+    @GuardedBy("this")
+    private HttpRoute route;
+
+    @GuardedBy("this")
+    private Object state;
+
+    @GuardedBy("this")
+    private long updated;
+
+    @GuardedBy("this")
+    private long expiry;
+
+    @GuardedBy("this")
+    private boolean leased;
+
+    @GuardedBy("this")
+    private volatile boolean shutdown;
+
+    public BasicHttpClientConnectionManager(
+            final SchemeRegistry schemeRegistry,
+            final DnsResolver dnsResolver,
+            final HttpConnectionFactory<DefaultClientConnection> connFactory) {
+        if (schemeRegistry == null) {
+            throw new IllegalArgumentException("Scheme registry may not be null");
+        }
+        this.connectionOperator = new HttpClientConnectionOperator(schemeRegistry, dnsResolver);
+        this.connFactory = connFactory != null ? connFactory : DefaultClientConnectionFactory.INSTANCE;
+        this.expiry = Long.MAX_VALUE;
+    }
+
+    public BasicHttpClientConnectionManager(final SchemeRegistry schemeRegistry) {
+        this(schemeRegistry, null, null);
+    }
+
+    public BasicHttpClientConnectionManager() {
+        this(SchemeRegistryFactory.createDefault(), null, null);
+    }
+
+    @Override
+    protected void finalize() throws Throwable {
+        try {
+            shutdown();
+        } finally { // Make sure we call overridden method even if shutdown barfs
+            super.finalize();
+        }
+    }
+
+    public SchemeRegistry getSchemeRegistry() {
+        return this.connectionOperator.getSchemeRegistry();
+    }
+
+    HttpRoute getRoute() {
+        return route;
+    }
+
+    Object getState() {
+        return state;
+    }
+
+    public final ConnectionRequest requestConnection(
+            final HttpRoute route,
+            final Object state) {
+        if (route == null) {
+            throw new IllegalArgumentException("Route may not be null");
+        }
+        return new ConnectionRequest() {
+
+            public boolean cancel() {
+                // Nothing to abort, since requests are immediate.
+                return false;
+            }
+
+            public HttpClientConnection get(long timeout, TimeUnit tunit) {
+                return BasicHttpClientConnectionManager.this.getConnection(
+                        route, state);
+            }
+
+        };
+    }
+
+    private void closeConnection() {
+        if (this.conn != null) {
+            this.log.debug("Closing connection");
+            try {
+                this.conn.close();
+            } catch (IOException iox) {
+                if (this.log.isDebugEnabled()) {
+                    this.log.debug("I/O exception closing connection", iox);
+                }
+            }
+            this.conn = null;
+        }
+    }
+
+    private void shutdownConnection() {
+        if (this.conn != null) {
+            this.log.debug("Shutting down connection");
+            try {
+                this.conn.shutdown();
+            } catch (IOException iox) {
+                if (this.log.isDebugEnabled()) {
+                    this.log.debug("I/O exception shutting down connection", iox);
+                }
+            }
+            this.conn = null;
+        }
+    }
+
+    private void checkExpiry() {
+        if (this.conn != null && System.currentTimeMillis() >= this.expiry) {
+            if (this.log.isDebugEnabled()) {
+                this.log.debug("Connection expired @ " + new Date(this.expiry));
+            }
+            closeConnection();
+        }
+    }
+
+    synchronized HttpClientConnection getConnection(final HttpRoute route, final Object state) {
+        if (this.shutdown) {
+            throw new IllegalStateException("Connection manager has been shut down");
+        }
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("Get connection for route " + route);
+        }
+        if (this.leased) {
+            throw new IllegalStateException("Connection is still allocated");
+        }
+        if (!LangUtils.equals(this.route, route) || !LangUtils.equals(this.state, state)) {
+            closeConnection();
+        }
+        this.route = route;
+        this.state = state;
+        checkExpiry();
+        if (this.conn == null) {
+            this.conn = this.connFactory.create();
+        }
+        this.leased = true;
+        return this.conn;
+    }
+
+    public synchronized void releaseConnection(
+            final HttpClientConnection conn,
+            final Object state,
+            long keepalive, final TimeUnit tunit) {
+        if (conn == null) {
+            throw new IllegalArgumentException("Connection may not be null");
+        }
+        if (conn != this.conn) {
+            throw new IllegalArgumentException("Connection not obtained from this manager");
+        }
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("Releasing connection " + conn);
+        }
+        if (this.shutdown) {
+            shutdownConnection();
+            return;
+        }
+        try {
+            this.updated = System.currentTimeMillis();
+            if (!this.conn.isOpen()) {
+                this.conn = null;
+                this.route = null;
+                this.conn = null;
+                this.expiry = Long.MAX_VALUE;
+            } else {
+                this.state = state;
+                if (this.log.isDebugEnabled()) {
+                    String s;
+                    if (keepalive > 0) {
+                        s = "for " + keepalive + " " + tunit;
+                    } else {
+                        s = "indefinitely";
+                    }
+                    this.log.debug("Connection can be kept alive " + s);
+                }
+                if (keepalive > 0) {
+                    this.expiry = this.updated + tunit.toMillis(keepalive);
+                } else {
+                    this.expiry = Long.MAX_VALUE;
+                }
+            }
+        } finally {
+            this.leased = false;
+        }
+    }
+
+    public void connect(
+            final HttpClientConnection conn,
+            final HttpHost host,
+            final InetAddress local,
+            final HttpContext context,
+            final HttpParams params) throws IOException {
+        if (conn == null) {
+            throw new IllegalArgumentException("Connection may not be null");
+        }
+        if (host == null) {
+            throw new IllegalArgumentException("HTTP host may not be null");
+        }
+        if (conn != this.conn) {
+            throw new IllegalArgumentException("Connection not obtained from this manager");
+        }
+        this.connectionOperator.connect(this.conn, host, local, context, params);
+    }
+
+    public void upgrade(
+            final HttpClientConnection conn,
+            final HttpHost host,
+            final HttpContext context,
+            final HttpParams params) throws IOException {
+        if (conn == null) {
+            throw new IllegalArgumentException("Connection may not be null");
+        }
+        if (host == null) {
+            throw new IllegalArgumentException("HTTP host may not be null");
+        }
+        if (conn != this.conn) {
+            throw new IllegalArgumentException("Connection not obtained from this manager");
+        }
+        this.connectionOperator.upgrade(this.conn, host, context, params);
+    }
+
+    public synchronized void closeExpiredConnections() {
+        if (this.shutdown) {
+            return;
+        }
+        if (!this.leased) {
+            checkExpiry();
+        }
+    }
+
+    public synchronized void closeIdleConnections(long idletime, TimeUnit tunit) {
+        if (tunit == null) {
+            throw new IllegalArgumentException("Time unit must not be null.");
+        }
+        if (this.shutdown) {
+            return;
+        }
+        if (!this.leased) {
+            long time = tunit.toMillis(idletime);
+            if (time < 0) {
+                time = 0;
+            }
+            long deadline = System.currentTimeMillis() - time;
+            if (this.updated <= deadline) {
+                closeConnection();
+            }
+        }
+    }
+
+    public synchronized void shutdown() {
+        if (this.shutdown) {
+            return;
+        }
+        this.shutdown = true;
+        shutdownConnection();
+    }
+
+}

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

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

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

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java (from r1398094, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpConnPool.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpConnPool.java&r1=1398094&r2=1405507&rev=1405507&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpConnPool.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java Sun Nov  4 07:37:50 2012
@@ -31,40 +31,42 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.commons.logging.Log;
-import org.apache.http.conn.OperatedClientConnection;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.annotation.ThreadSafe;
+import org.apache.http.conn.HttpClientConnectionManager;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.pool.AbstractConnPool;
 import org.apache.http.pool.ConnFactory;
 
 /**
- * @since 4.2
+ * @since 4.3
  */
-class HttpConnPool extends AbstractConnPool<HttpRoute, OperatedClientConnection, HttpPoolEntry> {
+@ThreadSafe
+class CPool extends AbstractConnPool<HttpRoute, DefaultClientConnection, CPoolEntry> {
 
     private static AtomicLong COUNTER = new AtomicLong();
 
-    private final Log log;
+    private final Log log = LogFactory.getLog(HttpClientConnectionManager.class);
     private final long timeToLive;
     private final TimeUnit tunit;
 
-    public HttpConnPool(final Log log,
+    public CPool(
             final int defaultMaxPerRoute, final int maxTotal,
             final long timeToLive, final TimeUnit tunit) {
         super(new InternalConnFactory(), defaultMaxPerRoute, maxTotal);
-        this.log = log;
         this.timeToLive = timeToLive;
         this.tunit = tunit;
     }
 
     @Override
-    protected HttpPoolEntry createEntry(final HttpRoute route, final OperatedClientConnection conn) {
+    protected CPoolEntry createEntry(final HttpRoute route, final DefaultClientConnection conn) {
         String id = Long.toString(COUNTER.getAndIncrement());
-        return new HttpPoolEntry(this.log, id, route, conn, this.timeToLive, this.tunit);
+        return new CPoolEntry(this.log, id, route, conn, this.timeToLive, this.tunit);
     }
 
-    static class InternalConnFactory implements ConnFactory<HttpRoute, OperatedClientConnection> {
+    static class InternalConnFactory implements ConnFactory<HttpRoute, DefaultClientConnection> {
 
-        public OperatedClientConnection create(final HttpRoute route) throws IOException {
+        public DefaultClientConnection create(final HttpRoute route) throws IOException {
             return new DefaultClientConnection();
         }
 

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java (from r1398094, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpPoolEntry.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpPoolEntry.java&r1=1398094&r2=1405507&rev=1405507&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpPoolEntry.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java Sun Nov  4 07:37:50 2012
@@ -31,28 +31,27 @@ import java.util.Date;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.logging.Log;
-import org.apache.http.conn.OperatedClientConnection;
+import org.apache.http.HttpClientConnection;
+import org.apache.http.annotation.ThreadSafe;
 import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.conn.routing.RouteTracker;
 import org.apache.http.pool.PoolEntry;
 
 /**
- * @since 4.2
+ * @since 4.3
  */
-class HttpPoolEntry extends PoolEntry<HttpRoute, OperatedClientConnection> {
+@ThreadSafe
+class CPoolEntry extends PoolEntry<HttpRoute, DefaultClientConnection> {
 
     private final Log log;
-    private final RouteTracker tracker;
 
-    public HttpPoolEntry(
+    public CPoolEntry(
             final Log log,
             final String id,
             final HttpRoute route,
-            final OperatedClientConnection conn,
+            final DefaultClientConnection conn,
             final long timeToLive, final TimeUnit tunit) {
         super(id, route, conn, timeToLive, tunit);
         this.log = log;
-        this.tracker = new RouteTracker(route);
     }
 
     @Override
@@ -64,27 +63,15 @@ class HttpPoolEntry extends PoolEntry<Ht
         return expired;
     }
 
-    RouteTracker getTracker() {
-        return this.tracker;
-    }
-
-    HttpRoute getPlannedRoute() {
-        return getRoute();
-    }
-
-    HttpRoute getEffectiveRoute() {
-        return this.tracker.toRoute();
-    }
-
     @Override
     public boolean isClosed() {
-        OperatedClientConnection conn = getConnection();
+        HttpClientConnection conn = getConnection();
         return !conn.isOpen();
     }
 
     @Override
     public void close() {
-        OperatedClientConnection conn = getConnection();
+        HttpClientConnection conn = getConnection();
         try {
             conn.close();
         } catch (IOException ex) {

Added: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java?rev=1405507&view=auto
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java (added)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java Sun Nov  4 07:37:50 2012
@@ -0,0 +1,165 @@
+/*
+ * ====================================================================
+ *
+ *  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.impl.conn;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+import org.apache.http.HttpClientConnection;
+import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.conn.HttpSSLConnection;
+import org.apache.http.protocol.HttpContext;
+
+/**
+ * @since 4.3
+ */
+@NotThreadSafe
+class CPoolProxy implements InvocationHandler {
+
+    private volatile CPoolEntry poolEntry;
+
+    CPoolProxy(final CPoolEntry entry) {
+        super();
+        this.poolEntry = entry;
+    }
+
+    CPoolEntry getPoolEntry() {
+        return this.poolEntry;
+    }
+
+    CPoolEntry detach() {
+        CPoolEntry local = this.poolEntry;
+        this.poolEntry = null;
+        return local;
+    }
+
+    HttpClientConnection getConnection() {
+        CPoolEntry local = this.poolEntry;
+        if (local == null) {
+            return null;
+        }
+        return local.getConnection();
+    }
+
+    public void close() throws IOException {
+        CPoolEntry local = this.poolEntry;
+        if (local != null) {
+            HttpClientConnection conn = local.getConnection();
+            conn.close();
+        }
+    }
+
+    public void shutdown() throws IOException {
+        CPoolEntry local = this.poolEntry;
+        if (local != null) {
+            HttpClientConnection conn = local.getConnection();
+            conn.shutdown();
+        }
+    }
+
+    public boolean isOpen() {
+        HttpClientConnection conn = getConnection();
+        if (conn != null) {
+            return conn.isOpen();
+        } else {
+            return false;
+        }
+    }
+
+    public boolean isStale() {
+        HttpClientConnection conn = getConnection();
+        if (conn != null) {
+            return conn.isStale();
+        } else {
+            return true;
+        }
+    }
+
+    public Object invoke(
+            final Object proxy, final Method method, final Object[] args) throws Throwable {
+        String mname = method.getName();
+        if (mname.equals("close")) {
+            close();
+            return null;
+        } else if (mname.equals("shutdown")) {
+            shutdown();
+            return null;
+        } else if (mname.equals("isOpen")) {
+            return isOpen();
+        } else if (mname.equals("isStale")) {
+            return isStale();
+        } else {
+            HttpClientConnection conn = getConnection();
+            if (conn == null) {
+                throw new ConnectionShutdownException();
+            }
+            try {
+                return method.invoke(conn, args);
+            } catch (InvocationTargetException ex) {
+                Throwable cause = ex.getCause();
+                if (cause != null) {
+                    throw cause;
+                } else {
+                    throw ex;
+                }
+            }
+        }
+    }
+
+    public static HttpClientConnection newProxy(
+            final CPoolEntry poolEntry) {
+        return (HttpClientConnection) Proxy.newProxyInstance(
+                CPoolProxy.class.getClassLoader(),
+                new Class<?>[] { HttpClientConnection.class, HttpSSLConnection.class, HttpContext.class },
+                new CPoolProxy(poolEntry));
+    }
+
+    private static CPoolProxy getHandler(
+            final HttpClientConnection proxy) {
+        InvocationHandler handler = Proxy.getInvocationHandler(proxy);
+        if (!CPoolProxy.class.isInstance(handler)) {
+            throw new IllegalStateException("Unexpected proxy handler class: " + handler);
+        }
+        return CPoolProxy.class.cast(handler);
+    }
+
+    public static CPoolEntry getPoolEntry(final HttpClientConnection proxy) {
+        CPoolEntry entry = getHandler(proxy).getPoolEntry();
+        if (entry == null) {
+            throw new ConnectionShutdownException();
+        }
+        return entry;
+    }
+
+    public static CPoolEntry detach(final HttpClientConnection proxy) {
+        return getHandler(proxy).detach();
+    }
+
+}

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

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

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



Mime
View raw message