hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r450978 - in /jakarta/httpcomponents/httpcore/trunk: module-main/src/examples/org/apache/http/examples/ module-main/src/main/java/org/apache/http/protocol/ module-nio/src/examples/org/apache/http/nio/examples/
Date Thu, 28 Sep 2006 19:26:51 GMT
Author: olegk
Date: Thu Sep 28 12:26:50 2006
New Revision: 450978

URL: http://svn.apache.org/viewvc?view=rev&rev=450978
Log:
[HTTPCORE-13] AbstractHttpProcessor is not really abstract

Changelog:
----------
* HttpService does no longer directly import impl classes

Modified:
    jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpServer.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpService.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/examples/org/apache/http/nio/examples/AsyncHttpServer.java

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpServer.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpServer.java?view=diff&rev=450978&r1=450977&r2=450978
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpServer.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpServer.java
Thu Sep 28 12:26:50 2006
@@ -48,7 +48,9 @@
 import org.apache.http.entity.ContentProducer;
 import org.apache.http.entity.EntityTemplate;
 import org.apache.http.entity.FileEntity;
+import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpParams;
+import org.apache.http.impl.DefaultHttpResponseFactory;
 import org.apache.http.impl.DefaultHttpServerConnection;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
@@ -184,8 +186,11 @@
                     httpproc.addInterceptor(new ResponseServer());
                     httpproc.addInterceptor(new ResponseContent());
                     httpproc.addInterceptor(new ResponseConnControl());
-
-                    HttpService httpService = new HttpService(httpproc);
+                    
+                    HttpService httpService = new HttpService(
+                            httpproc, 
+                            new DefaultConnectionReuseStrategy(), 
+                            new DefaultHttpResponseFactory());
                     httpService.setParams(this.params);
                     httpService.registerRequestHandler("*", new HttpFileHandler());
                     

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpService.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpService.java?view=diff&rev=450978&r1=450977&r2=450978
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpService.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpService.java
Thu Sep 28 12:26:50 2006
@@ -47,8 +47,6 @@
 import org.apache.http.MethodNotSupportedException;
 import org.apache.http.ProtocolException;
 import org.apache.http.UnsupportedHttpVersionException;
-import org.apache.http.impl.DefaultConnectionReuseStrategy;
-import org.apache.http.impl.DefaultHttpResponseFactory;
 import org.apache.http.params.HttpParams;
 
 /**
@@ -60,29 +58,38 @@
  */
 public class HttpService {
 
+    private final Map handlerMap;
+    
     private HttpParams params = null;
-    private final HttpProcessor processor;
+    private HttpProcessor processor = null;
     private ConnectionReuseStrategy connStrategy = null;
     private HttpResponseFactory responseFactory = null;
     
-    private final Map handlerMap;
-    
     /**
      * Create a new HTTP service.
      *
-     * @param proc      the processor to use on requests and responses
+     * @param proc             the processor to use on requests and responses
+     * @param connStrategy     the connection reuse strategy
+     * @param responseFactory  the response factory
      */
-    public HttpService(HttpProcessor proc) {
-        if (proc == null)
-            throw new IllegalArgumentException
-                ("HTTP processor must not be null.");
-
-        this.processor = proc;
+    public HttpService(
+            final HttpProcessor proc,
+            final ConnectionReuseStrategy connStrategy,
+            final HttpResponseFactory responseFactory) {
+        super();
         this.handlerMap = new HashMap();
-        this.connStrategy = new DefaultConnectionReuseStrategy();
-        this.responseFactory = new DefaultHttpResponseFactory();
+        setHttpProcessor(proc);
+        setConnReuseStrategy(connStrategy);
+        setResponseFactory(responseFactory);
     }
     
+    protected void setHttpProcessor(final HttpProcessor processor) {
+        if (processor == null) {
+            throw new IllegalArgumentException("HTTP processor may not be null.");
+        }
+        this.processor = processor;
+    }
+
     protected void setConnReuseStrategy(final ConnectionReuseStrategy connStrategy) {
         if (connStrategy == null) {
             throw new IllegalArgumentException("Connection reuse strategy may not be null");

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/examples/org/apache/http/nio/examples/AsyncHttpServer.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/examples/org/apache/http/nio/examples/AsyncHttpServer.java?view=diff&rev=450978&r1=450977&r2=450978
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/examples/org/apache/http/nio/examples/AsyncHttpServer.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/examples/org/apache/http/nio/examples/AsyncHttpServer.java
Thu Sep 28 12:26:50 2006
@@ -20,7 +20,9 @@
 import org.apache.http.entity.ContentProducer;
 import org.apache.http.entity.EntityTemplate;
 import org.apache.http.entity.FileEntity;
+import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpParams;
+import org.apache.http.impl.DefaultHttpResponseFactory;
 import org.apache.http.nio.IOConsumer;
 import org.apache.http.nio.IOEventDispatch;
 import org.apache.http.nio.IOProducer;
@@ -104,7 +106,10 @@
             httpProcessor.addInterceptor(new ResponseContent());
             httpProcessor.addInterceptor(new ResponseConnControl());
 
-            HttpService httpService = new HttpService(httpProcessor);
+            HttpService httpService = new HttpService(
+                    httpProcessor, 
+                    new DefaultConnectionReuseStrategy(), 
+                    new DefaultHttpResponseFactory());
             httpService.setParams(this.params);
             httpService.registerRequestHandler("*", new HttpFileHandler());
             



Mime
View raw message