hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rola...@apache.org
Subject svn commit: r509260 - in /jakarta/httpcomponents/httpclient/trunk/src: examples/org/apache/http/examples/client/ examples/org/apache/http/examples/conn/ java/org/apache/http/conn/ java/org/apache/http/impl/conn/
Date Mon, 19 Feb 2007 17:16:32 GMT
Author: rolandw
Date: Mon Feb 19 09:16:30 2007
New Revision: 509260

URL: http://svn.apache.org/viewvc?view=rev&rev=509260
Log:
improved connection creation and scheme registry support in manager

Modified:
    jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/client/ClientExecuteDirect.java
    jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java
    jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/conn/ManagerConnectDirect.java
    jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/conn/ManagerConnectProxy.java
    jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/conn/OperatorConnectDirect.java
    jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/conn/OperatorConnectProxy.java
    jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/ClientConnectionOperator.java
    jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
    jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/conn/ThreadSafeClientConnManager.java

Modified: jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/client/ClientExecuteDirect.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/client/ClientExecuteDirect.java?view=diff&rev=509260&r1=509259&r2=509260
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/client/ClientExecuteDirect.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/client/ClientExecuteDirect.java
Mon Feb 19 09:16:30 2007
@@ -136,10 +136,10 @@
     private final static HttpClient createHttpClient() {
 
         ClientConnectionManager ccm =
-            new ThreadSafeClientConnManager(getParams());
+            new ThreadSafeClientConnManager(getParams(), supportedSchemes);
 
         DefaultHttpClient dhc =
-            new DefaultHttpClient(getParams(), ccm, null);
+            new DefaultHttpClient(getParams(), ccm, supportedSchemes);
 
         BasicHttpProcessor bhp = dhc.getProcessor();
         // Required protocol interceptors
@@ -160,9 +160,7 @@
      */
     private final static void setup() {
 
-        //@@@ use dedicated SchemeRegistry instance
-        //@@@ currently no way to pass it to TSCCM
-        supportedSchemes = SchemeRegistry.DEFAULT; //new SchemeRegistry();
+        supportedSchemes = new SchemeRegistry();
 
         // Register the "http" protocol scheme, it is required
         // by the default operator to look up socket factories.

Modified: jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java?view=diff&rev=509260&r1=509259&r2=509260
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java
Mon Feb 19 09:16:30 2007
@@ -148,7 +148,7 @@
     private final static HttpClient createHttpClient() {
 
         ClientConnectionManager ccm =
-            new ThreadSafeClientConnManager(getParams());
+            new ThreadSafeClientConnManager(getParams(), supportedSchemes);
 
         DefaultHttpClient dhc =
             new DefaultHttpClient(getParams(), ccm, supportedSchemes);
@@ -172,9 +172,7 @@
      */
     private final static void setup() {
 
-        //@@@ use dedicated SchemeRegistry instance
-        //@@@ currently no way to pass it to TSCCM
-        supportedSchemes = SchemeRegistry.DEFAULT; //new SchemeRegistry();
+        supportedSchemes = new SchemeRegistry();
 
         // Register the "http" and "https" protocol schemes, they are
         // required by the default operator to look up socket factories.

Modified: jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/conn/ManagerConnectDirect.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/conn/ManagerConnectDirect.java?view=diff&rev=509260&r1=509259&r2=509260
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/conn/ManagerConnectDirect.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/conn/ManagerConnectDirect.java
Mon Feb 19 09:16:30 2007
@@ -154,12 +154,7 @@
 
     private final static ClientConnectionManager createManager() {
 
-        return new ThreadSafeClientConnManager(getParams()) {
-            //@@@ need better way to pass in the SchemeRegistry or operator
-            protected ClientConnectionOperator createConnectionOperator() {
-                return new DefaultClientConnectionOperator(supportedSchemes);
-            }
-         };
+        return new ThreadSafeClientConnManager(getParams(), supportedSchemes);
     }
 
 

Modified: jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/conn/ManagerConnectProxy.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/conn/ManagerConnectProxy.java?view=diff&rev=509260&r1=509259&r2=509260
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/conn/ManagerConnectProxy.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/conn/ManagerConnectProxy.java
Mon Feb 19 09:16:30 2007
@@ -182,12 +182,7 @@
 
     private final static ClientConnectionManager createManager() {
 
-        return new ThreadSafeClientConnManager(getParams()) {
-            //@@@ need better way to pass in the SchemeRegistry or operator
-            protected ClientConnectionOperator createConnectionOperator() {
-                return new DefaultClientConnectionOperator(supportedSchemes);
-            }
-         };
+        return new ThreadSafeClientConnManager(getParams(), supportedSchemes);
     }
 
 

Modified: jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/conn/OperatorConnectDirect.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/conn/OperatorConnectDirect.java?view=diff&rev=509260&r1=509259&r2=509260
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/conn/OperatorConnectDirect.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/conn/OperatorConnectDirect.java
Mon Feb 19 09:16:30 2007
@@ -50,7 +50,6 @@
 import org.apache.http.conn.PlainSocketFactory;
 import org.apache.http.conn.OperatedClientConnection;
 import org.apache.http.conn.ClientConnectionOperator;
-import org.apache.http.impl.conn.DefaultClientConnection;
 import org.apache.http.impl.conn.DefaultClientConnectionOperator;
 
 
@@ -98,8 +97,8 @@
         setup(); // some general setup
 
         // one operator can be used for many connections
-        ClientConnectionOperator  scop = createOperator();
-        OperatedClientConnection conn = createConnection();
+        ClientConnectionOperator scop = createOperator();
+        OperatedClientConnection conn = scop.createConnection();
 
         HttpRequest req = createRequest(target);
         HttpContext ctx = createContext();
@@ -131,10 +130,6 @@
 
     private final static ClientConnectionOperator createOperator() {
         return new DefaultClientConnectionOperator(supportedSchemes);
-    }
-
-    private final static OperatedClientConnection createConnection() {
-        return new DefaultClientConnection();
     }
 
 

Modified: jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/conn/OperatorConnectProxy.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/conn/OperatorConnectProxy.java?view=diff&rev=509260&r1=509259&r2=509260
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/conn/OperatorConnectProxy.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/src/examples/org/apache/http/examples/conn/OperatorConnectProxy.java
Mon Feb 19 09:16:30 2007
@@ -51,7 +51,6 @@
 import org.apache.http.conn.ssl.SSLSocketFactory;
 import org.apache.http.conn.OperatedClientConnection;
 import org.apache.http.conn.ClientConnectionOperator;
-import org.apache.http.impl.conn.DefaultClientConnection;
 import org.apache.http.impl.conn.DefaultClientConnectionOperator;
 
 
@@ -103,8 +102,8 @@
         setup(); // some general setup
 
         // one operator can be used for many connections
-        ClientConnectionOperator  scop = createOperator();
-        OperatedClientConnection conn = createConnection();
+        ClientConnectionOperator scop = createOperator();
+        OperatedClientConnection conn = scop.createConnection();
 
         HttpRequest req = createRequest(target);
         HttpContext ctx = createContext();
@@ -163,10 +162,6 @@
 
     private final static ClientConnectionOperator createOperator() {
         return new DefaultClientConnectionOperator(supportedSchemes);
-    }
-
-    private final static OperatedClientConnection createConnection() {
-        return new DefaultClientConnection();
     }
 
 

Modified: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/ClientConnectionOperator.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/ClientConnectionOperator.java?view=diff&rev=509260&r1=509259&r2=509260
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/ClientConnectionOperator.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/ClientConnectionOperator.java
Mon Feb 19 09:16:30 2007
@@ -62,6 +62,15 @@
 
 
     /**
+     * Creates a new connection that can be operated.
+     *
+     * @return  a new, unopened connection for use with this operator
+     */
+    OperatedClientConnection createConnection()
+        ;
+
+
+    /**
      * Opens a connection to the given target host.
      *
      * @param conn      the connection to open

Modified: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/conn/DefaultClientConnectionOperator.java?view=diff&rev=509260&r1=509259&r2=509260
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
Mon Feb 19 09:16:30 2007
@@ -90,6 +90,11 @@
     }
 
 
+    // non-javadoc, see interface ClientConnectionOperator
+    public OperatedClientConnection createConnection() {
+        return new DefaultClientConnection();
+    }
+
 
     // non-javadoc, see interface ClientConnectionOperator
     public void openConnection(OperatedClientConnection conn,

Modified: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/conn/ThreadSafeClientConnManager.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/conn/ThreadSafeClientConnManager.java?view=diff&rev=509260&r1=509259&r2=509260
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/conn/ThreadSafeClientConnManager.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/conn/ThreadSafeClientConnManager.java
Mon Feb 19 09:16:30 2007
@@ -47,6 +47,7 @@
 import org.apache.http.conn.ClientConnectionManager;
 import org.apache.http.conn.ClientConnectionOperator;
 import org.apache.http.conn.ConnectionPoolTimeoutException;
+import org.apache.http.conn.SchemeRegistry;
 import org.apache.http.conn.HttpRoute;
 import org.apache.http.conn.RouteTracker;
 import org.apache.http.conn.HostConfiguration;
@@ -114,7 +115,7 @@
     private ConnectionPool connectionPool;
 
     /** The operator for opening and updating connections. */
-    private ClientConnectionOperator connectionOperator;
+    private ClientConnectionOperator connOperator;
 
     /** Indicates whether this connection manager is shut down. */
     private volatile boolean isShutDown;
@@ -125,15 +126,18 @@
      * Creates a new thread safe connection manager.
      *
      * @param params    the parameters for this manager
+     * @param schreg    the scheme registry, or
+     *                  <code>null</code> for the default registry
      */
-    public ThreadSafeClientConnManager(HttpParams params) {
+    public ThreadSafeClientConnManager(HttpParams params,
+                                       SchemeRegistry schreg) {
 
         if (params == null) {
             throw new IllegalArgumentException("Parameters must not be null.");
         }
         this.params = params;
         this.connectionPool = new ConnectionPool();
-        this.connectionOperator = createConnectionOperator();
+        this.connOperator = createConnectionOperator(schreg);
         this.isShutDown = false;
 
         synchronized(ALL_CONNECTION_MANAGERS) {
@@ -306,26 +310,12 @@
      */
     private TrackingPoolEntry createPoolEntry(HostConfiguration route) {
 
-        OperatedClientConnection occ = createOperatedConnection();
+        OperatedClientConnection occ = connOperator.createConnection();
         return connectionPool.createEntry(route, occ);
     }
 
 
     /**
-     * Hook for creating an operated connection to be managed.
-     * Derived classes can override this method to change the
-     * instantiation of operated connections.
-     * The default implementation here instantiates
-     * {@link DefaultClientConnection DefaultClientConnection}.
-     *
-     * @return  a new connection to be managed
-     */
-    protected OperatedClientConnection createOperatedConnection() {
-        return new DefaultClientConnection();
-    }
-
-
-    /**
      * Hook for creating the connection operator.
      * It is called by the constructor.
      * Derived classes can override this method to change the
@@ -333,10 +323,14 @@
      * The default implementation here instantiates
      * {@link DefaultClientConnectionOperator DefaultClientConnectionOperator}.
      *
+     * @param schreg    the scheme registry to use, or <code>null</code>
+     *
      * @return  the connection operator to use
      */
-    protected ClientConnectionOperator createConnectionOperator() {
-        return new DefaultClientConnectionOperator();
+    protected ClientConnectionOperator
+        createConnectionOperator(SchemeRegistry schreg) {
+
+        return new DefaultClientConnectionOperator(schreg);
     }
 
     
@@ -1186,7 +1180,7 @@
             this.tracker = new RouteTracker(route);
             final HttpHost proxy  = route.getProxyHost();
 
-            ThreadSafeClientConnManager.this.connectionOperator.openConnection
+            ThreadSafeClientConnManager.this.connOperator.openConnection
                 (this.connection,
                  (proxy != null) ? proxy : route.getTargetHost(),
                  context, params);
@@ -1276,7 +1270,7 @@
                 LOG.debug("Layer protocol on connection to " + target);
             }
 
-            ThreadSafeClientConnManager.this.connectionOperator
+            ThreadSafeClientConnManager.this.connOperator
                 .updateSecureConnection(this.connection, target,
                                         context, params);
 



Mime
View raw message