hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r449427 - in /jakarta/httpcomponents/httpasync/trunk/src: contrib/org/apache/http/async/contrib/routing/ examples/org/apache/http/examples/ java/org/apache/http/async/ java/org/apache/http/async/impl/
Date Sun, 24 Sep 2006 16:30:49 GMT
Author: olegk
Date: Sun Sep 24 09:30:48 2006
New Revision: 449427

URL: http://svn.apache.org/viewvc?view=rev&rev=449427
Log:
[HTTPCORE-8] refactor HttpClientConnection and HttpProxyConnection

Changelog:
----------
* HttpCore: HttpClientConnection#open() method is no more
* HttpAsync: Added HttpAsyncClientConnection interface, which extends HttpClientConnection
and preserves the semantics of HttpClientConnection that existed before the changes to the
interface

Added:
    jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/HttpAsyncClientConnection.java
  (with props)
    jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/impl/SimpleHttpAsyncClientConnection.java
  (with props)
Modified:
    jakarta/httpcomponents/httpasync/trunk/src/contrib/org/apache/http/async/contrib/routing/RoutingAsyncGet.java
    jakarta/httpcomponents/httpasync/trunk/src/examples/org/apache/http/examples/ElementalAsyncGet.java
    jakarta/httpcomponents/httpasync/trunk/src/examples/org/apache/http/examples/NotifiedAsyncGet.java
    jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/AbstractHttpDispatcher.java
    jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/AsyncHttpProcessor.java
    jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/impl/SimpleHttpDispatcher.java

Modified: jakarta/httpcomponents/httpasync/trunk/src/contrib/org/apache/http/async/contrib/routing/RoutingAsyncGet.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpasync/trunk/src/contrib/org/apache/http/async/contrib/routing/RoutingAsyncGet.java?view=diff&rev=449427&r1=449426&r2=449427
==============================================================================
--- jakarta/httpcomponents/httpasync/trunk/src/contrib/org/apache/http/async/contrib/routing/RoutingAsyncGet.java
(original)
+++ jakarta/httpcomponents/httpasync/trunk/src/contrib/org/apache/http/async/contrib/routing/RoutingAsyncGet.java
Sun Sep 24 09:30:48 2006
@@ -30,25 +30,25 @@
 package org.apache.http.async.contrib.routing;
 
 
-import org.apache.http.HttpClientConnection;
+import org.apache.http.ConnectionReuseStrategy;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpVersion;
 import org.apache.http.Scheme;
-import org.apache.http.ConnectionReuseStrategy;
+import org.apache.http.async.AsyncHttpProcessor;
+import org.apache.http.async.HttpAsyncClientConnection;
+import org.apache.http.async.HttpDispatcher;
+import org.apache.http.async.HttpHandle;
+import org.apache.http.async.HttpNotificationHandler;
+import org.apache.http.async.impl.SimpleHttpAsyncClientConnection;
+import org.apache.http.async.impl.SimpleHttpDispatcher;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
-import org.apache.http.impl.DefaultHttpClientConnection;
 import org.apache.http.impl.DefaultHttpParams;
 import org.apache.http.impl.io.PlainSocketFactory;
 import org.apache.http.io.SocketFactory;
 import org.apache.http.message.HttpGet;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpProtocolParams;
-import org.apache.http.async.HttpDispatcher;
-import org.apache.http.async.HttpHandle;
-import org.apache.http.async.HttpNotificationHandler;
-import org.apache.http.async.AsyncHttpProcessor;
-import org.apache.http.async.impl.SimpleHttpDispatcher;
 import org.apache.http.protocol.RequestConnControl;
 import org.apache.http.protocol.RequestContent;
 import org.apache.http.protocol.RequestTargetHost;
@@ -232,7 +232,7 @@
         HttpProtocolParams.setUserAgent(params, "Jakarta-HttpComponents/1.1");
         HttpProtocolParams.setUseExpectContinue(params, false);
 
-        HttpClientConnection conn = new DefaultHttpClientConnection();
+        HttpAsyncClientConnection conn = new SimpleHttpAsyncClientConnection();
 
         AsyncHttpProcessor proc = new AsyncHttpProcessor();
         proc.setParams(params);

Modified: jakarta/httpcomponents/httpasync/trunk/src/examples/org/apache/http/examples/ElementalAsyncGet.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpasync/trunk/src/examples/org/apache/http/examples/ElementalAsyncGet.java?view=diff&rev=449427&r1=449426&r2=449427
==============================================================================
--- jakarta/httpcomponents/httpasync/trunk/src/examples/org/apache/http/examples/ElementalAsyncGet.java
(original)
+++ jakarta/httpcomponents/httpasync/trunk/src/examples/org/apache/http/examples/ElementalAsyncGet.java
Sun Sep 24 09:30:48 2006
@@ -30,24 +30,24 @@
 package org.apache.http.examples;
 
 
-import org.apache.http.HttpClientConnection;
+import org.apache.http.ConnectionReuseStrategy;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpVersion;
 import org.apache.http.Scheme;
-import org.apache.http.ConnectionReuseStrategy;
+import org.apache.http.async.AsyncHttpProcessor;
+import org.apache.http.async.HttpAsyncClientConnection;
+import org.apache.http.async.HttpDispatcher;
+import org.apache.http.async.HttpHandle;
+import org.apache.http.async.impl.SimpleHttpAsyncClientConnection;
+import org.apache.http.async.impl.SimpleHttpDispatcher;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
-import org.apache.http.impl.DefaultHttpClientConnection;
 import org.apache.http.impl.DefaultHttpParams;
 import org.apache.http.impl.io.PlainSocketFactory;
 import org.apache.http.io.SocketFactory;
 import org.apache.http.message.HttpGet;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpProtocolParams;
-import org.apache.http.async.HttpDispatcher;
-import org.apache.http.async.HttpHandle;
-import org.apache.http.async.AsyncHttpProcessor;
-import org.apache.http.async.impl.SimpleHttpDispatcher;
 import org.apache.http.protocol.RequestConnControl;
 import org.apache.http.protocol.RequestContent;
 import org.apache.http.protocol.RequestTargetHost;
@@ -160,7 +160,7 @@
         HttpProtocolParams.setUserAgent(params, "Jakarta-HttpComponents/1.1");
         HttpProtocolParams.setUseExpectContinue(params, false);
 
-        HttpClientConnection conn = new DefaultHttpClientConnection();
+        HttpAsyncClientConnection conn = new SimpleHttpAsyncClientConnection();
 
         AsyncHttpProcessor proc = new AsyncHttpProcessor();
         proc.setParams(params);

Modified: jakarta/httpcomponents/httpasync/trunk/src/examples/org/apache/http/examples/NotifiedAsyncGet.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpasync/trunk/src/examples/org/apache/http/examples/NotifiedAsyncGet.java?view=diff&rev=449427&r1=449426&r2=449427
==============================================================================
--- jakarta/httpcomponents/httpasync/trunk/src/examples/org/apache/http/examples/NotifiedAsyncGet.java
(original)
+++ jakarta/httpcomponents/httpasync/trunk/src/examples/org/apache/http/examples/NotifiedAsyncGet.java
Sun Sep 24 09:30:48 2006
@@ -32,25 +32,25 @@
 
 import java.util.LinkedList;
 
-import org.apache.http.HttpClientConnection;
+import org.apache.http.ConnectionReuseStrategy;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpVersion;
 import org.apache.http.Scheme;
-import org.apache.http.ConnectionReuseStrategy;
+import org.apache.http.async.AsyncHttpProcessor;
+import org.apache.http.async.HttpAsyncClientConnection;
+import org.apache.http.async.HttpDispatcher;
+import org.apache.http.async.HttpHandle;
+import org.apache.http.async.HttpNotificationHandler;
+import org.apache.http.async.impl.SimpleHttpAsyncClientConnection;
+import org.apache.http.async.impl.SimpleHttpDispatcher;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
-import org.apache.http.impl.DefaultHttpClientConnection;
 import org.apache.http.impl.DefaultHttpParams;
 import org.apache.http.impl.io.PlainSocketFactory;
 import org.apache.http.io.SocketFactory;
 import org.apache.http.message.HttpGet;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpProtocolParams;
-import org.apache.http.async.HttpDispatcher;
-import org.apache.http.async.HttpHandle;
-import org.apache.http.async.HttpNotificationHandler;
-import org.apache.http.async.AsyncHttpProcessor;
-import org.apache.http.async.impl.SimpleHttpDispatcher;
 import org.apache.http.protocol.RequestConnControl;
 import org.apache.http.protocol.RequestContent;
 import org.apache.http.protocol.RequestTargetHost;
@@ -259,7 +259,7 @@
         HttpProtocolParams.setUserAgent(params, "Jakarta-HttpComponents/1.1");
         HttpProtocolParams.setUseExpectContinue(params, false);
 
-        HttpClientConnection conn = new DefaultHttpClientConnection();
+        HttpAsyncClientConnection conn = new SimpleHttpAsyncClientConnection();
 
         AsyncHttpProcessor proc = new AsyncHttpProcessor();
         proc.setParams(params);

Modified: jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/AbstractHttpDispatcher.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/AbstractHttpDispatcher.java?view=diff&rev=449427&r1=449426&r2=449427
==============================================================================
--- jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/AbstractHttpDispatcher.java
(original)
+++ jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/AbstractHttpDispatcher.java
Sun Sep 24 09:30:48 2006
@@ -219,10 +219,10 @@
      * @throws HttpException      in case of a problem
      * @throws IOException        in case of an IO problem
      */
-    protected static void transmitRequestTo(AsyncHttpProcessor   proc,
-                                            HttpRequest          request,
-                                            HttpContext          context,
-                                            HttpClientConnection connection)
+    protected static void transmitRequestTo(AsyncHttpProcessor        proc,
+                                            HttpRequest               request,
+                                            HttpContext               context,
+                                            HttpAsyncClientConnection connection)
         throws HttpException, IOException {
 
         proc.asyncSendRequest(request, connection, context);

Modified: jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/AsyncHttpProcessor.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/AsyncHttpProcessor.java?view=diff&rev=449427&r1=449426&r2=449427
==============================================================================
--- jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/AsyncHttpProcessor.java
(original)
+++ jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/AsyncHttpProcessor.java
Sun Sep 24 09:30:48 2006
@@ -87,7 +87,9 @@
      * @throws HttpException      in case of a problem
      * @throws IOException        in case of an IO problem
      */
-    protected void doEstablishConnection(final HttpClientConnection conn, final HttpHost
target,
+    protected void doEstablishConnection(
+            final HttpAsyncClientConnection conn, 
+            final HttpHost target,
             final HttpParams params) throws HttpException, IOException {
         if (conn == null) {
             throw new IllegalArgumentException("HTTP connection may not be null");
@@ -132,9 +134,9 @@
      * @throws HttpException      in case of a problem
      * @throws IOException        in case of an IO problem
      */
-    protected void asyncSendRequest(HttpRequest          request,
-                                    HttpClientConnection connection,
-                                    HttpContext          context)
+    protected void asyncSendRequest(HttpRequest               request,
+                                    HttpAsyncClientConnection connection,
+                                    HttpContext               context)
         throws HttpException, IOException {
 
         if (request == null)

Added: jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/HttpAsyncClientConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/HttpAsyncClientConnection.java?view=auto&rev=449427
==============================================================================
--- jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/HttpAsyncClientConnection.java
(added)
+++ jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/HttpAsyncClientConnection.java
Sun Sep 24 09:30:48 2006
@@ -0,0 +1,51 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed 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.async;
+
+import java.io.IOException;
+
+import org.apache.http.HttpClientConnection;
+import org.apache.http.HttpHost;
+import org.apache.http.params.HttpParams;
+
+/**
+ *
+ * <!-- empty lines above to avoid 'svn diff' context problems -->
+ * @version $Revision$ $Date$
+ * 
+ * @since 4.0
+ */
+public interface HttpAsyncClientConnection extends HttpClientConnection {
+
+    void open(HttpParams params) throws IOException;
+    
+    void setTargetHost(HttpHost targethost);
+    
+}

Propchange: jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/HttpAsyncClientConnection.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/HttpAsyncClientConnection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/impl/SimpleHttpAsyncClientConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/impl/SimpleHttpAsyncClientConnection.java?view=auto&rev=449427
==============================================================================
--- jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/impl/SimpleHttpAsyncClientConnection.java
(added)
+++ jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/impl/SimpleHttpAsyncClientConnection.java
Sun Sep 24 09:30:48 2006
@@ -0,0 +1,86 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed 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.async.impl;
+
+import java.io.IOException;
+import java.net.Socket;
+
+import org.apache.http.HttpHost;
+import org.apache.http.async.HttpAsyncClientConnection;
+import org.apache.http.impl.DefaultHttpClientConnection;
+import org.apache.http.io.SocketFactory;
+import org.apache.http.params.HttpParams;
+
+/**
+ *
+ * <!-- empty lines above to avoid 'svn diff' context problems -->
+ * @version $Revision$ $Date$
+ * 
+ * @since 4.0
+ */
+public class SimpleHttpAsyncClientConnection 
+    extends DefaultHttpClientConnection implements HttpAsyncClientConnection {
+
+    private HttpHost targethost = null;
+    
+    public SimpleHttpAsyncClientConnection(final HttpHost targethost) {
+        super();
+        this.targethost = targethost;
+    }
+    
+    public SimpleHttpAsyncClientConnection() {
+        this(null);
+    }
+    
+    public void open(final HttpParams params) throws IOException {
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        if (this.targethost == null) {
+            throw new IllegalStateException("Target host not specified");
+        }
+        assertNotOpen();
+        SocketFactory socketfactory = this.targethost.getScheme().getSocketFactory();
+        Socket socket = socketfactory.createSocket(
+                this.targethost.getHostName(), this.targethost.getPort(), 
+                null, 0, 
+                params);
+        bind(socket, this.targethost, params);
+    }    
+
+    public void setTargetHost(final HttpHost targethost) {
+        if (targethost == null) {
+            throw new IllegalArgumentException("Target host may not be null");
+        }
+        assertNotOpen();
+        this.targethost = targethost;
+    }
+    
+}

Propchange: jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/impl/SimpleHttpAsyncClientConnection.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/impl/SimpleHttpAsyncClientConnection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/impl/SimpleHttpDispatcher.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/impl/SimpleHttpDispatcher.java?view=diff&rev=449427&r1=449426&r2=449427
==============================================================================
--- jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/impl/SimpleHttpDispatcher.java
(original)
+++ jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/impl/SimpleHttpDispatcher.java
Sun Sep 24 09:30:48 2006
@@ -39,12 +39,12 @@
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpHost;
-import org.apache.http.HttpClientConnection;
 import org.apache.http.ConnectionReuseStrategy;
 import org.apache.http.HttpException;
 import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpExecutionContext;
+import org.apache.http.async.HttpAsyncClientConnection;
 import org.apache.http.async.HttpHandle;
 import org.apache.http.async.HttpDispatcher;
 import org.apache.http.async.HttpDispatcherParams;
@@ -86,7 +86,7 @@
     private final HttpContext context;
     
     /** The one and only connection. */
-    private final HttpClientConnection client_connection;
+    private final HttpAsyncClientConnection client_connection;
 
     /**
      * The HTTP processor.
@@ -136,9 +136,9 @@
      * @param reuse     the strategy for re-using connections, or
      *                  <code>null</code> to disable connection re-use
      */
-    public SimpleHttpDispatcher(HttpClientConnection    conn,
-                                AsyncHttpProcessor      proc,
-                                ConnectionReuseStrategy reuse) {
+    public SimpleHttpDispatcher(HttpAsyncClientConnection    conn,
+                                AsyncHttpProcessor           proc,
+                                ConnectionReuseStrategy      reuse) {
         super(null);
 
         if (conn == null)



Mime
View raw message