hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r604514 - in /jakarta/httpcomponents/httpcore/trunk/module-main/src: main/java/org/apache/http/ main/java/org/apache/http/params/ main/java/org/apache/http/protocol/ test/java/org/apache/http/ test/java/org/apache/http/protocol/
Date Sat, 15 Dec 2007 20:49:41 GMT
Author: olegk
Date: Sat Dec 15 12:49:40 2007
New Revision: 604514

URL: http://svn.apache.org/viewvc?rev=604514&view=rev
Log:
HTTPCORE-133: Clone support
* updated classes in packages o.a.h, o.a.h.params, o.a.h.protocol (HttpHost, ProtocolVersion,
BasicHttpParams, BasicHttpProcessor)

Modified:
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpHost.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/ProtocolVersion.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/BasicHttpParams.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/BasicHttpProcessor.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/TestHttpHost.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/TestHttpVersion.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/protocol/TestBasicHttpProcessor.java

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpHost.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpHost.java?rev=604514&r1=604513&r2=604514&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpHost.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpHost.java
Sat Dec 15 12:49:40 2007
@@ -45,7 +45,7 @@
  * 
  * @since 4.0
  */
-public class HttpHost {
+public final class HttpHost implements Cloneable {
 
     /** The default scheme is "http". */
     public static final String DEFAULT_SCHEME_NAME = "http";
@@ -209,4 +209,8 @@
         return hash;
     }
 
+    public Object clone() throws CloneNotSupportedException {
+        return super.clone();
+    }
+    
 }

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/ProtocolVersion.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/ProtocolVersion.java?rev=604514&r1=604513&r2=604514&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/ProtocolVersion.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/ProtocolVersion.java
Sat Dec 15 12:49:40 2007
@@ -53,7 +53,7 @@
  * 
  * @version $Revision$
  */
-public class ProtocolVersion implements Serializable {
+public class ProtocolVersion implements Serializable, Cloneable {
 
     private static final long serialVersionUID = 8287599752106796338L;
 
@@ -280,4 +280,8 @@
         return buffer.toString();
     }
 
+    public Object clone() throws CloneNotSupportedException {
+        return super.clone();
+    }
+    
 }

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/BasicHttpParams.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/BasicHttpParams.java?rev=604514&r1=604513&r2=604514&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/BasicHttpParams.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/BasicHttpParams.java
Sat Dec 15 12:49:40 2007
@@ -49,8 +49,8 @@
  * 
  * @version $Revision$
  */
-public class BasicHttpParams extends AbstractHttpParams
-    implements HttpLinkedParams, Serializable {
+public final class BasicHttpParams extends AbstractHttpParams
+    implements HttpLinkedParams, Serializable, Cloneable {
 
     static final long serialVersionUID = 4571099216197814749L;
 
@@ -171,11 +171,17 @@
      *          are <i>not</i> copied.
      */
     public HttpParams copy() {
-        BasicHttpParams bhp = new BasicHttpParams(this.defaults);
-        copyParams(bhp);
-        return bhp;
+        BasicHttpParams clone = new BasicHttpParams(this.defaults);
+        copyParams(clone);
+        return clone;
     }
 
+    public Object clone() throws CloneNotSupportedException {
+        BasicHttpParams clone = (BasicHttpParams) super.clone();
+        copyParams(clone);
+        return clone;
+    }
+ 
     /**
      * Copies the locally defined parameters to the argument parameters.
      * Default parameters accessible via {@link #getDefaults}

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/BasicHttpProcessor.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/BasicHttpProcessor.java?rev=604514&r1=604513&r2=604514&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/BasicHttpProcessor.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/BasicHttpProcessor.java
Sat Dec 15 12:49:40 2007
@@ -52,8 +52,8 @@
  * 
  * @since 4.0
  */
-public class BasicHttpProcessor implements
-    HttpProcessor, HttpRequestInterceptorList, HttpResponseInterceptorList {
+public final class BasicHttpProcessor implements
+    HttpProcessor, HttpRequestInterceptorList, HttpResponseInterceptorList, Cloneable {
 
     protected List requestInterceptors = null; 
     protected List responseInterceptors = null;
@@ -305,6 +305,17 @@
             }
         }
     }
+
+    protected void copyInterceptors(final BasicHttpProcessor target) {
+        if (this.requestInterceptors != null) {
+            target.requestInterceptors =
+                new ArrayList(this.requestInterceptors);
+        }
+        if (this.responseInterceptors != null) {
+            target.responseInterceptors =
+                new ArrayList(this.responseInterceptors);
+        }
+    }
     
     /**
      * Creates a copy of this instance
@@ -313,14 +324,13 @@
      */
     public BasicHttpProcessor copy() {
         BasicHttpProcessor clone = new BasicHttpProcessor();
-        if (this.requestInterceptors != null) {
-            clone.requestInterceptors =
-                new ArrayList(this.requestInterceptors);
-        }
-        if (this.responseInterceptors != null) {
-            clone.responseInterceptors =
-                new ArrayList(this.responseInterceptors);
-        }
+        copyInterceptors(clone);
+        return clone;
+    }
+    
+    public Object clone() throws CloneNotSupportedException {
+        BasicHttpProcessor clone = (BasicHttpProcessor) super.clone();
+        copyInterceptors(clone);
         return clone;
     }
  

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/TestHttpHost.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/TestHttpHost.java?rev=604514&r1=604513&r2=604514&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/TestHttpHost.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/TestHttpHost.java
Sat Dec 15 12:49:40 2007
@@ -140,4 +140,10 @@
         assertEquals("somehost:8888", host4.toHostString());
     }
 
+    public void testCloning() throws Exception {
+        HttpHost orig = new HttpHost("somehost", 8080, "https");
+        HttpHost clone = (HttpHost) orig.clone();
+        assertEquals(orig, clone);
+    }
+    
 }

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/TestHttpVersion.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/TestHttpVersion.java?rev=604514&r1=604513&r2=604514&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/TestHttpVersion.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/TestHttpVersion.java
Sat Dec 15 12:49:40 2007
@@ -117,5 +117,11 @@
         assertTrue(HttpVersion.HTTP_1_0.compareToVersion(HttpVersion.HTTP_1_0) == 0);
    }
     
+    public void testCloning() throws Exception {
+        HttpVersion orig = HttpVersion.HTTP_1_1;
+        HttpVersion clone = (HttpVersion) orig.clone();
+        assertEquals(orig, clone);
+    }
+    
 }
 

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/protocol/TestBasicHttpProcessor.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/protocol/TestBasicHttpProcessor.java?rev=604514&r1=604513&r2=604514&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/protocol/TestBasicHttpProcessor.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/protocol/TestBasicHttpProcessor.java
Sat Dec 15 12:49:40 2007
@@ -84,8 +84,6 @@
     }
 
     public void testAddTailRequestInterceptorNull() {
-        System.out.println("testAddTailRequestInterceptorNull");
-
         HttpRequestInterceptor itcp = null;
         BasicHttpProcessor instance = new BasicHttpProcessor();
 



Mime
View raw message