commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r413837 - /jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java
Date Tue, 13 Jun 2006 08:35:00 GMT
Author: olegk
Date: Tue Jun 13 01:35:00 2006
New Revision: 413837

URL: http://svn.apache.org/viewvc?rev=413837&view=rev
Log:
[HTTPCLIENT-420] Provide a non-pooling connection manager

Changelog:
Added an option to the simple connection manager to disable connection persistence

Contributed by Oleg Kalnichevski
Reviewed by Roland Weber and Michael Becke

Modified:
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java

Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java?rev=413837&r1=413836&r2=413837&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java
Tue Jun 13 01:35:00 2006
@@ -71,7 +71,6 @@
             try {
                 lastResponse.close();
             } catch (IOException ioe) {
-                //FIXME: badness - close to force reconnect.
                 conn.close();
             }
         }
@@ -97,8 +96,29 @@
      * It will not be used to enforce thread safety.
      */
     private volatile boolean inUse = false;
+
+    private boolean alwaysClose = false;
+
+    /**
+     * The connection manager created with this constructor will try to keep the 
+     * connection open (alive) between consecutive requests if the alwaysClose 
+     * parameter is set to <tt>false</tt>. Otherwise the connection manager will

+     * always close connections upon release.
+     * 
+     * @param alwaysClose if set <tt>true</tt>, the connection manager will always
+     *    close connections upon release.
+     */
+    public SimpleHttpConnectionManager(boolean alwaysClose) {
+        super();
+        this.alwaysClose = alwaysClose;
+    }
     
+    /**
+     * The connection manager created with this constructor will always try to keep 
+     * the connection open (alive) between consecutive requests.
+     */
     public SimpleHttpConnectionManager() {
+        super();
     }
     
     /**
@@ -203,8 +223,12 @@
         if (conn != httpConnection) {
             throw new IllegalStateException("Unexpected release of an unknown connection.");
         }
-
-        finishLastResponse(httpConnection);
+        if (this.alwaysClose) {
+            httpConnection.close();
+        } else {
+            // make sure the connection is reuseable
+            finishLastResponse(httpConnection);
+        }
         
         inUse = false;
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message