hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rola...@apache.org
Subject svn commit: r558799 - in /jakarta/httpcomponents/httpclient/trunk/module-client/src: examples/org/apache/http/examples/client/ examples/org/apache/http/examples/conn/ main/java/org/apache/http/impl/conn/ main/java/org/apache/http/impl/conn/tsccm/ test/...
Date Mon, 23 Jul 2007 17:07:30 GMT
Author: rolandw
Date: Mon Jul 23 10:07:28 2007
New Revision: 558799

URL: http://svn.apache.org/viewvc?view=rev&rev=558799
Log:
HTTPCLIENT-636: move TSCCM to separate package

Added:
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/TSCCMConnAdapter.java
  (with props)
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
      - copied, changed from r558783, jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/ThreadSafeClientConnManager.java
Removed:
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/ThreadSafeClientConnManager.java
Modified:
    jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientExecuteDirect.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/conn/ManagerConnectDirect.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/conn/ManagerConnectProxy.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientExecuteDirect.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientExecuteDirect.java?view=diff&rev=558799&r1=558798&r2=558799
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientExecuteDirect.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientExecuteDirect.java
Mon Jul 23 10:07:28 2007
@@ -47,7 +47,7 @@
 import org.apache.http.conn.SchemeRegistry;
 import org.apache.http.conn.SocketFactory;
 import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.impl.conn.ThreadSafeClientConnManager;
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
 import org.apache.http.message.BasicHttpRequest;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java?view=diff&rev=558799&r1=558798&r2=558799
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java
Mon Jul 23 10:07:28 2007
@@ -48,7 +48,7 @@
 import org.apache.http.conn.SocketFactory;
 import org.apache.http.conn.ssl.SSLSocketFactory;
 import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.impl.conn.ThreadSafeClientConnManager;
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
 import org.apache.http.message.BasicHttpRequest;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java?view=diff&rev=558799&r1=558798&r2=558799
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java
Mon Jul 23 10:07:28 2007
@@ -42,7 +42,7 @@
 import org.apache.http.conn.params.HttpConnectionManagerParams;
 import org.apache.http.conn.ssl.SSLSocketFactory;
 import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.impl.conn.ThreadSafeClientConnManager;
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpProtocolParams;

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/conn/ManagerConnectDirect.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/conn/ManagerConnectDirect.java?view=diff&rev=558799&r1=558798&r2=558799
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/conn/ManagerConnectDirect.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/conn/ManagerConnectDirect.java
Mon Jul 23 10:07:28 2007
@@ -44,7 +44,7 @@
 import org.apache.http.conn.Scheme;
 import org.apache.http.conn.SchemeRegistry;
 import org.apache.http.conn.SocketFactory;
-import org.apache.http.impl.conn.ThreadSafeClientConnManager;
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
 import org.apache.http.message.BasicHttpRequest;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/conn/ManagerConnectProxy.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/conn/ManagerConnectProxy.java?view=diff&rev=558799&r1=558798&r2=558799
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/conn/ManagerConnectProxy.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/conn/ManagerConnectProxy.java
Mon Jul 23 10:07:28 2007
@@ -45,7 +45,7 @@
 import org.apache.http.conn.SchemeRegistry;
 import org.apache.http.conn.SocketFactory;
 import org.apache.http.conn.ssl.SSLSocketFactory;
-import org.apache.http.impl.conn.ThreadSafeClientConnManager;
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
 import org.apache.http.message.BasicHttpRequest;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;

Added: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/TSCCMConnAdapter.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/TSCCMConnAdapter.java?view=auto&rev=558799
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/TSCCMConnAdapter.java
(added)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/TSCCMConnAdapter.java
Mon Jul 23 10:07:28 2007
@@ -0,0 +1,85 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  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.tsccm;
+
+
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.impl.conn.AbstractPoolEntry;
+import org.apache.http.impl.conn.AbstractPooledConnAdapter;
+
+
+
+/**
+ * A connection wrapper and callback handler.
+ * All connections given out by the manager are wrappers which
+ * can be {@link #detach detach}ed to prevent further use on release.
+ */
+public class TSCCMConnAdapter extends AbstractPooledConnAdapter {
+
+    /**
+     * Creates a new adapter.
+     *
+     * @param tsccm   the connection manager
+     * @param entry   the pool entry for the connection being wrapped
+     */
+    protected TSCCMConnAdapter(ThreadSafeClientConnManager tsccm,
+                               AbstractPoolEntry entry) {
+        super(tsccm, entry);
+        super.markedReusable = true;
+    }
+
+
+    /**
+     * Obtains the connection manager.
+     *
+     * @return  the connection manager, or <code>null</code> if detached
+     */
+    protected ClientConnectionManager getManager() {
+        return super.connManager;
+    }
+
+
+    /**
+     * Obtains the pool entry.
+     *
+     * @return  the pool entry, or <code>null</code> if detached
+     */
+    protected AbstractPoolEntry getPoolEntry() {
+        return super.poolEntry;
+    }
+
+
+    // non-javadoc, see base class
+    protected void detach() {
+        // override needed only to make method visible in this package
+        super.detach();
+    }
+}

Propchange: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/TSCCMConnAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/TSCCMConnAdapter.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/TSCCMConnAdapter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
(from r558783, jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/ThreadSafeClientConnManager.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java?view=diff&rev=558799&p1=jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/ThreadSafeClientConnManager.java&r1=558783&p2=jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java&r2=558799
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/ThreadSafeClientConnManager.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
Mon Jul 23 10:07:28 2007
@@ -28,7 +28,7 @@
  *
  */
 
-package org.apache.http.impl.conn;
+package org.apache.http.impl.conn.tsccm;
 
 import java.io.IOException;
 import java.lang.ref.Reference;
@@ -54,6 +54,7 @@
 import org.apache.http.conn.SchemeRegistry;
 import org.apache.http.conn.params.HttpConnectionManagerParams;
 import org.apache.http.params.HttpParams;
+import org.apache.http.impl.conn.*; //@@@ specify
 
 
 /**
@@ -187,7 +188,7 @@
 
         final TrackingPoolEntry entry = doGetConnection(route, timeout);
 
-        return new HttpConnectionAdapter(entry);
+        return new TSCCMConnAdapter(this, entry);
     }
 
 
@@ -361,15 +362,13 @@
      */
     public void releaseConnection(ManagedClientConnection conn) {
 
-        if (!(conn instanceof HttpConnectionAdapter)) {
+        if (!(conn instanceof TSCCMConnAdapter)) {
             throw new IllegalArgumentException
                 ("Connection class mismatch, " +
                  "connection not obtained from this manager.");
         }
-        HttpConnectionAdapter hca = (HttpConnectionAdapter) conn;
-        if ((hca.poolEntry != null) &&
-            //@@@ (hca.poolEntry.manager != this) &&
-            (hca.connManager != this)) {
+        TSCCMConnAdapter hca = (TSCCMConnAdapter) conn;
+        if ((hca.getPoolEntry() != null) && (hca.getManager() != this)) {
             throw new IllegalArgumentException
                 ("Connection not obtained from this manager.");
         }
@@ -397,7 +396,7 @@
                 LOG.debug("Exception shutting down released connection.",
                           iox);
         } finally {
-            TrackingPoolEntry entry = (TrackingPoolEntry) hca.poolEntry;
+            TrackingPoolEntry entry = (TrackingPoolEntry) hca.getPoolEntry();
             hca.detach();
             releasePoolEntry(entry);
         }
@@ -560,7 +559,7 @@
         // to avoid holding the lock for too long
         for (Iterator i = connectionsToClose.iterator(); i.hasNext();) {
             TrackingPoolEntry entry = (TrackingPoolEntry) i.next();
-            closeConnection(entry.connection);
+            closeConnection(entry.getConnection());
             entry.manager.releasePoolEntry(entry);
         }
     }
@@ -730,7 +729,7 @@
             while (iter.hasNext()) {
                 TrackingPoolEntry entry = (TrackingPoolEntry) iter.next();
                 iter.remove();
-                closeConnection(entry.connection);
+                closeConnection(entry.getConnection());
             }
 
             if (refWorker != null)
@@ -742,7 +741,7 @@
                 iter.remove();
                 TrackingPoolEntry entry = (TrackingPoolEntry) per.get();
                 if (entry != null) {
-                    closeConnection(entry.connection);
+                    closeConnection(entry.getConnection());
                 }
             }
             //@@@ while the static map exists, call there to clean it up
@@ -889,7 +888,7 @@
                 }
 
                 // remove the connection from the timeout handler
-                idleConnectionHandler.remove(entry.connection);
+                idleConnectionHandler.remove(entry.getConnection());
             } else if (LOG.isDebugEnabled()) {
                 LOG.debug("There were no free connections to get, route=" 
                     + route);
@@ -907,7 +906,7 @@
             while (iter.hasNext()) {
                 TrackingPoolEntry entry =
                     (TrackingPoolEntry) iter.next();
-                if (!entry.connection.isOpen()) {
+                if (!entry.getConnection().isOpen()) {
                     iter.remove();
                     deleteConnection(entry);
                 }
@@ -935,13 +934,13 @@
          */
         private synchronized void deleteConnection(TrackingPoolEntry entry) {
 
-            HttpRoute route = entry.plannedRoute;
+            HttpRoute route = entry.getPlannedRoute();
 
             if (LOG.isDebugEnabled()) {
                 LOG.debug("Reclaiming connection, route=" + route);
             }
 
-            closeConnection(entry.connection);
+            closeConnection(entry.getConnection());
 
             RouteConnPool routePool = getRoutePool(route);
             
@@ -952,7 +951,7 @@
                 mapRoutes.remove(route);
 
             // remove the connection from the timeout handler
-            idleConnectionHandler.remove(entry.connection);
+            idleConnectionHandler.remove(entry.getConnection());
         }
 
         /**
@@ -1029,7 +1028,7 @@
          */
         private void freeConnection(TrackingPoolEntry entry) {
 
-            HttpRoute route = entry.plannedRoute;
+            HttpRoute route = entry.getPlannedRoute();
 
             if (LOG.isDebugEnabled()) {
                 LOG.debug("Freeing connection, route=" + route);
@@ -1040,7 +1039,7 @@
                 if (isShutDown) {
                     // the connection manager has been shutdown, release the
                     // connection's resources and get out of here
-                    closeConnection(entry.connection);
+                    closeConnection(entry.getConnection());
                     return;
                 }
                 
@@ -1068,7 +1067,7 @@
                 }
 
                 // register the connection with the timeout handler
-                idleConnectionHandler.add(entry.connection);
+                idleConnectionHandler.add(entry.getConnection());
 
                 notifyWaitingThread(routePool);
             }
@@ -1295,7 +1294,7 @@
                 throw new IllegalArgumentException
                     ("Pool entry must not be null.");
             }
-            route = entry.plannedRoute;
+            route = ((TrackingPoolEntry)entry).getPlannedRoute();
         }
 
 
@@ -1306,6 +1305,8 @@
          *         <code>false</code> otherwise
          */
         public final boolean isValid() {
+            //@@@ method currently not used
+            //@@@ better sematics: allow explicit invalidation
             return (super.get() != null);
         }
 
@@ -1377,29 +1378,39 @@
         }
 
 
+        private final OperatedClientConnection getConnection() {
+            return super.connection;
+        }
+
+        private final HttpRoute getPlannedRoute() {
+            return super.plannedRoute;
+        }
+
     } // class TrackingPoolEntry
 
     
-    /**
+    /* *
+     * @@@ replace by separate class TSCCMConnAdapter
      * A connection wrapper and callback handler.
      * All connections given out by the manager are wrappers which
      * can be {@link #detach detach}ed to prevent further use on release.
-     */
+     * /
     private class HttpConnectionAdapter extends AbstractPooledConnAdapter {
         //@@@ HTTPCLIENT-653
         //@@@ this adapter being a nested class prevents proper detaching of
         //@@@ the adapter from the manager, and therefore GC of the manager
 
-        /**
+        / * *
          * Creates a new adapter.
          *
          * @param entry   the pool entry for the connection being wrapped
-         */
+         * /
         protected HttpConnectionAdapter(TrackingPoolEntry entry) {
             super(ThreadSafeClientConnManager.this, entry);
             super.markedReusable = true;
         }
     }
+    */
 
 } // class ThreadSafeClientConnManager
 

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java?view=diff&rev=558799&r1=558798&r2=558799
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java
Mon Jul 23 10:07:28 2007
@@ -47,6 +47,7 @@
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpProtocolParams;
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
 
 
 /**

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java?view=diff&rev=558799&r1=558798&r2=558799
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java
Mon Jul 23 10:07:28 2007
@@ -52,6 +52,7 @@
 import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.util.EntityUtils;
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
 
 
 /**



Mime
View raw message