hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1432452 - in /httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn: CPool.java CPoolProxy.java PoolingHttpClientConnectionManager.java
Date Sat, 12 Jan 2013 15:25:59 GMT
Author: olegk
Date: Sat Jan 12 15:25:59 2013
New Revision: 1432452

URL: http://svn.apache.org/viewvc?rev=1432452&view=rev
Log:
Minor tweaks in the connection management code

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java?rev=1432452&r1=1432451&r2=1432452&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java
Sat Jan 12 15:25:59 2013
@@ -32,7 +32,6 @@ import java.util.concurrent.atomic.Atomi
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.http.annotation.ThreadSafe;
-import org.apache.http.conn.HttpClientConnectionManager;
 import org.apache.http.conn.SocketClientConnection;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.pool.AbstractConnPool;
@@ -46,7 +45,7 @@ class CPool extends AbstractConnPool<Htt
 
     private static AtomicLong COUNTER = new AtomicLong();
 
-    private final Log log = LogFactory.getLog(HttpClientConnectionManager.class);
+    private final Log log = LogFactory.getLog(CPool.class);
     private final long timeToLive;
     private final TimeUnit tunit;
 

Modified: 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=1432452&r1=1432451&r2=1432452&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java
Sat Jan 12 15:25:59 2013
@@ -33,6 +33,7 @@ import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 
 import org.apache.http.HttpClientConnection;
+import org.apache.http.HttpConnection;
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.conn.SocketClientConnection;
 import org.apache.http.protocol.HttpContext;
@@ -43,6 +44,22 @@ import org.apache.http.protocol.HttpCont
 @NotThreadSafe
 class CPoolProxy implements InvocationHandler {
 
+    private static final Method CLOSE_METHOD;
+    private static final Method SHUTDOWN_METHOD;
+    private static final Method IS_OPEN_METHOD;
+    private static final Method IS_STALE_METHOD;
+
+    static {
+        try {
+            CLOSE_METHOD = HttpConnection.class.getMethod("close");
+            SHUTDOWN_METHOD = HttpConnection.class.getMethod("shutdown");
+            IS_OPEN_METHOD = HttpConnection.class.getMethod("isOpen");
+            IS_STALE_METHOD = HttpConnection.class.getMethod("isStale");
+        } catch (NoSuchMethodException ex) {
+            throw new Error(ex);
+        }
+    }
+
     private volatile CPoolEntry poolEntry;
 
     CPoolProxy(final CPoolEntry entry) {
@@ -104,16 +121,15 @@ class CPoolProxy implements InvocationHa
 
     public Object invoke(
             final Object proxy, final Method method, final Object[] args) throws Throwable
{
-        String mname = method.getName();
-        if (mname.equals("close")) {
+        if (method.equals(CLOSE_METHOD)) {
             close();
             return null;
-        } else if (mname.equals("shutdown")) {
+        } else if (method.equals(SHUTDOWN_METHOD)) {
             shutdown();
             return null;
-        } else if (mname.equals("isOpen")) {
+        } else if (method.equals(IS_OPEN_METHOD)) {
             return Boolean.valueOf(isOpen());
-        } else if (mname.equals("isStale")) {
+        } else if (method.equals(IS_STALE_METHOD)) {
             return Boolean.valueOf(isStale());
         } else {
             HttpClientConnection conn = getConnection();
@@ -137,7 +153,7 @@ class CPoolProxy implements InvocationHa
             final CPoolEntry poolEntry) {
         return (HttpClientConnection) Proxy.newProxyInstance(
                 CPoolProxy.class.getClassLoader(),
-                new Class<?>[] { HttpClientConnection.class, SocketClientConnection.class,
HttpContext.class },
+                new Class<?>[] { SocketClientConnection.class, HttpContext.class },
                 new CPoolProxy(poolEntry));
     }
 

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=1432452&r1=1432451&r2=1432452&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
Sat Jan 12 15:25:59 2013
@@ -84,7 +84,8 @@ import org.apache.http.util.Asserts;
  * @since 4.3
  */
 @ThreadSafe
-public class PoolingHttpClientConnectionManager implements HttpClientConnectionManager, Closeable
{
+public class PoolingHttpClientConnectionManager
+    implements HttpClientConnectionManager, ConnPoolControl<HttpRoute>, Closeable {
 
     private final Log log = LogFactory.getLog(getClass());
 



Mime
View raw message