hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r365341 - in /jakarta/httpcomponents/trunk: coyote-httpconnector/src/java/org/apache/http/coyote/impl/ http-core/src/contrib/org/apache/http/contrib/benchmark/ http-core/src/examples/org/apache/http/examples/ http-core/src/java/org/apache/h...
Date Mon, 02 Jan 2006 12:50:40 GMT
Author: olegk
Date: Mon Jan  2 04:50:10 2006
New Revision: 365341

URL: http://svn.apache.org/viewcvs?rev=365341&view=rev
Log:
The abstract HTTP processor redesigned

Modified:
    jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java
    jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpProcessingContext.java
    jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/benchmark/HttpBenchmark.java
    jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/benchmark/Stats.java
    jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpServer.java
    jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/HttpRequestExecutorDemo.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/HttpHead.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/AbstractHttpProcessor.java

Modified: jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java?rev=365341&r1=365340&r2=365341&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java
(original)
+++ jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java
Mon Jan  2 04:50:10 2006
@@ -147,10 +147,10 @@
         this.inbuffer = new byte[buffersize];
 
         // Add required protocol interceptors
-        addResponseInterceptor(new ResponseContent());
-        addResponseInterceptor(new ResponseConnControl());
-        addResponseInterceptor(new ResponseDate());
-        addResponseInterceptor(new ResponseServer());
+        addInterceptor(new ResponseContent());
+        addInterceptor(new ResponseConnControl());
+        addInterceptor(new ResponseDate());
+        addInterceptor(new ResponseServer());
         
         // Add connection to the HTTP context
         getContext().setAttribute(HttpProcessingContext.HTTP_CONNECTION, conn);

Modified: jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpProcessingContext.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpProcessingContext.java?rev=365341&r1=365340&r2=365341&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpProcessingContext.java
(original)
+++ jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpProcessingContext.java
Mon Jan  2 04:50:10 2006
@@ -77,4 +77,15 @@
         this.map.put(id, obj);
     }
     
+    public Object removeAttribute(final String id) {
+        if (id == null) {
+            throw new IllegalArgumentException("Id may not be null");
+        }
+        if (this.map != null) {
+            return this.map.remove(id);
+        } else {
+            return null;
+        }
+    }
+
 }

Modified: jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/benchmark/HttpBenchmark.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/benchmark/HttpBenchmark.java?rev=365341&r1=365340&r2=365341&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/benchmark/HttpBenchmark.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/benchmark/HttpBenchmark.java
Mon Jan  2 04:50:10 2006
@@ -81,12 +81,12 @@
         httpexecutor.setParams(params);
 
         // Required request interceptors
-        httpexecutor.addRequestInterceptor(new RequestContent());
-        httpexecutor.addRequestInterceptor(new RequestTargetHost());
+        httpexecutor.addInterceptor(new RequestContent());
+        httpexecutor.addInterceptor(new RequestTargetHost());
         // Recommended request interceptors
-        httpexecutor.addRequestInterceptor(new RequestConnControl());
-        httpexecutor.addRequestInterceptor(new RequestUserAgent());
-        httpexecutor.addRequestInterceptor(new RequestExpectContinue());
+        httpexecutor.addInterceptor(new RequestConnControl());
+        httpexecutor.addInterceptor(new RequestUserAgent());
+        httpexecutor.addInterceptor(new RequestExpectContinue());
         return httpexecutor;
     }
     

Modified: jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/benchmark/Stats.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/benchmark/Stats.java?rev=365341&r1=365340&r2=365341&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/benchmark/Stats.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/benchmark/Stats.java
Mon Jan  2 04:50:10 2006
@@ -1,7 +1,7 @@
 /*
- * $HeadURL: $
- * $Revision: $
- * $Date: $
+ * $HeadURL$
+ * $Revision$
+ * $Date$
  *
  * ====================================================================
  *
@@ -33,7 +33,7 @@
  * </p>
  * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
  *
- * @version $Revision: $
+ * @version $Revision$
  * 
  * @since 4.0
  */

Modified: jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpServer.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpServer.java?rev=365341&r1=365340&r2=365341&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpServer.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpServer.java
Mon Jan  2 04:50:10 2006
@@ -263,10 +263,10 @@
                     conn.bind(socket, this.params);
                     HttpRequestProcessor processor = new HttpRequestProcessor(conn);
                     // Add required protocol interceptors
-                    processor.addResponseInterceptor(new ResponseContent());
-                    processor.addResponseInterceptor(new ResponseConnControl());
-                    processor.addResponseInterceptor(new ResponseDate());
-                    processor.addResponseInterceptor(new ResponseServer());             
      
+                    processor.addInterceptor(new ResponseContent());
+                    processor.addInterceptor(new ResponseConnControl());
+                    processor.addInterceptor(new ResponseDate());
+                    processor.addInterceptor(new ResponseServer());                    
                     processor.setParams(this.params);
                     Thread t = new ConnectionProcessorThread(processor, new FileServiceHandler());
                     t.setDaemon(true);

Modified: jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/HttpRequestExecutorDemo.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/HttpRequestExecutorDemo.java?rev=365341&r1=365340&r2=365341&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/HttpRequestExecutorDemo.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/HttpRequestExecutorDemo.java
Mon Jan  2 04:50:10 2006
@@ -71,12 +71,12 @@
         HttpRequestExecutor httpexecutor = new HttpRequestExecutor();
         httpexecutor.setParams(params);
         // Required request interceptors
-        httpexecutor.addRequestInterceptor(new RequestContent());
-        httpexecutor.addRequestInterceptor(new RequestTargetHost());
+        httpexecutor.addInterceptor(new RequestContent());
+        httpexecutor.addInterceptor(new RequestTargetHost());
         // Recommended request interceptors
-        httpexecutor.addRequestInterceptor(new RequestConnControl());
-        httpexecutor.addRequestInterceptor(new RequestUserAgent());
-        httpexecutor.addRequestInterceptor(new RequestExpectContinue());
+        httpexecutor.addInterceptor(new RequestConnControl());
+        httpexecutor.addInterceptor(new RequestUserAgent());
+        httpexecutor.addInterceptor(new RequestExpectContinue());
         
         HttpHost host = new HttpHost("www.yahoo.com");
         HttpClientConnection conn = new DefaultHttpClientConnection(host);

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/HttpHead.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/HttpHead.java?rev=365341&r1=365340&r2=365341&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/HttpHead.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/HttpHead.java
Mon Jan  2 04:50:10 2006
@@ -1,7 +1,7 @@
 /*
- * $HeadURL: $
- * $Revision: $
- * $Date: $
+ * $HeadURL$
+ * $Revision$
+ * $Date$
  *
  * ====================================================================
  *

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/AbstractHttpProcessor.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/AbstractHttpProcessor.java?rev=365341&r1=365340&r2=365341&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/AbstractHttpProcessor.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/AbstractHttpProcessor.java
Mon Jan  2 04:50:10 2006
@@ -53,87 +53,90 @@
 
     private final HttpContext localContext;
     
-    private List interceptors = null; 
+    private List requestInterceptors = null; 
+    private List responseInterceptors = null; 
     
     public AbstractHttpProcessor(final HttpContext localContext) {
         super();
         this.localContext = localContext;
     }
     
-    private void addInterceptor(final Object obj) {
-        if (obj == null) {
+    public void addInterceptor(final HttpRequestInterceptor interceptor) {
+        if (interceptor == null) {
             return;
         }
-        if (this.interceptors == null) {
-            this.interceptors = new ArrayList();
+        if (this.requestInterceptors == null) {
+            this.requestInterceptors = new ArrayList();
         }
-        this.interceptors.add(obj);
+        this.requestInterceptors.add(interceptor);
     }
     
-    public void removeInterceptor(final Object obj) {
-        if (obj == null) {
+    public void removeInterceptor(final HttpRequestInterceptor interceptor) {
+        if (interceptor == null) {
             return;
         }
-        if (this.interceptors == null) {
+        if (this.requestInterceptors == null) {
             return;
         }
-        this.interceptors.remove(obj);
-        if (this.interceptors.isEmpty()) {
-            this.interceptors = null;
+        this.requestInterceptors.remove(interceptor);
+        if (this.requestInterceptors.isEmpty()) {
+            this.requestInterceptors = null;
         }
     }
     
-    public void addRequestInterceptor(final HttpRequestInterceptor interceptor) {
-        addInterceptor(interceptor);
-    }
-    
-    public void addResponseInterceptor(final HttpResponseInterceptor interceptor) {
-        addInterceptor(interceptor);
-    }
-
-    public void removeRequestInterceptor(final HttpRequestInterceptor interceptor) {
-        removeInterceptor(interceptor);
+    public void addInterceptor(final HttpResponseInterceptor interceptor) {
+        if (interceptor == null) {
+            return;
+        }
+        if (this.responseInterceptors == null) {
+            this.responseInterceptors = new ArrayList();
+        }
+        this.responseInterceptors.add(interceptor);
     }
     
-    public void removeResponseInterceptor(final HttpResponseInterceptor interceptor) {
-        removeInterceptor(interceptor);
+    public void removeInterceptor(final HttpResponseInterceptor interceptor) {
+        if (interceptor == null) {
+            return;
+        }
+        if (this.responseInterceptors == null) {
+            return;
+        }
+        this.responseInterceptors.remove(interceptor);
+        if (this.responseInterceptors.isEmpty()) {
+            this.responseInterceptors = null;
+        }
     }
     
     public void removeInterceptors(final Class clazz) {
         if (clazz == null) {
             return;
         }
-        if (this.interceptors == null) {
-            return;
+        if (this.requestInterceptors != null) {
+            for (Iterator i = this.requestInterceptors.iterator(); i.hasNext(); ) {
+                if (clazz.isInstance(i.next())) {
+                    i.remove();
+                }
+            }
         }
-        for (Iterator i = this.interceptors.iterator(); i.hasNext(); ) {
-            if (clazz.isInstance(i.next())) {
-                i.remove();
+        if (this.responseInterceptors != null) {
+            for (Iterator i = this.responseInterceptors.iterator(); i.hasNext(); ) {
+                if (clazz.isInstance(i.next())) {
+                    i.remove();
+                }
             }
         }
     }
     
-    public void setInterceptors(final List interceptors) {
-        if (interceptors == null) {
-            return;
-        }
-        if (this.interceptors != null) {
-            this.interceptors.clear();
-            this.interceptors.addAll(interceptors);
-        } else {
-            this.interceptors = new ArrayList(interceptors);
-        }
+    public void clearInterceptors() {
+        this.requestInterceptors = null;
+        this.responseInterceptors = null;
     }
     
     protected void preprocessRequest(final HttpMutableRequest request) 
             throws IOException, HttpException {
-        if (this.interceptors == null) {
-            return;
-        }
-        for (Iterator i = this.interceptors.iterator(); i.hasNext(); ) {
-            Object obj = i.next();
-            if (obj instanceof HttpRequestInterceptor) {
-                HttpRequestInterceptor interceptor = (HttpRequestInterceptor)obj;
+        if (this.requestInterceptors != null) {
+            for (Iterator i = this.requestInterceptors.iterator(); i.hasNext(); ) {
+                HttpRequestInterceptor interceptor = (HttpRequestInterceptor) i.next();
                 interceptor.process(request, this.localContext);
             }
         }
@@ -141,13 +144,9 @@
 
     protected void postprocessResponse(final HttpMutableResponse response) 
             throws IOException, HttpException {
-        if (this.interceptors == null) {
-            return;
-        }
-        for (Iterator i = this.interceptors.iterator(); i.hasNext(); ) {
-            Object obj = i.next();
-            if (obj instanceof HttpResponseInterceptor) {
-                HttpResponseInterceptor interceptor = (HttpResponseInterceptor)obj;
+        if (this.responseInterceptors != null) {
+            for (Iterator i = this.responseInterceptors.iterator(); i.hasNext(); ) {
+                HttpResponseInterceptor interceptor = (HttpResponseInterceptor) i.next();
                 interceptor.process(response, this.localContext);
             }
         }



Mime
View raw message