hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1124219 - in /httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http: impl/ impl/io/ io/
Date Wed, 18 May 2011 12:35:33 GMT
Author: olegk
Date: Wed May 18 12:35:32 2011
New Revision: 1124219

URL: http://svn.apache.org/viewvc?rev=1124219&view=rev
Log:
Generified message parsers and writers

Modified:
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageParser.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageWriter.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpRequestParser.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpRequestWriter.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpResponseParser.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpResponseWriter.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/io/HttpMessageParser.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/io/HttpMessageWriter.java

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java?rev=1124219&r1=1124218&r2=1124219&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java
Wed May 18 12:35:32 2011
@@ -76,8 +76,8 @@ public abstract class AbstractHttpClient
     private SessionInputBuffer inbuffer = null;
     private SessionOutputBuffer outbuffer = null;
     private EofSensor eofSensor = null;
-    private HttpMessageParser responseParser = null;
-    private HttpMessageWriter requestWriter = null;
+    private HttpMessageParser<HttpResponse> responseParser = null;
+    private HttpMessageWriter<HttpRequest> requestWriter = null;
     private HttpConnectionMetricsImpl metrics = null;
 
     /**
@@ -159,7 +159,7 @@ public abstract class AbstractHttpClient
      * @param params HTTP parameters.
      * @return HTTP message parser.
      */
-    protected HttpMessageParser createResponseParser(
+    protected HttpMessageParser<HttpResponse> createResponseParser(
             final SessionInputBuffer buffer,
             final HttpResponseFactory responseFactory,
             final HttpParams params) {
@@ -179,7 +179,7 @@ public abstract class AbstractHttpClient
      * @param params HTTP parameters
      * @return HTTP message writer
      */
-    protected HttpMessageWriter createRequestWriter(
+    protected HttpMessageWriter<HttpRequest> createRequestWriter(
             final SessionOutputBuffer buffer,
             final HttpParams params) {
         return new HttpRequestWriter(buffer, null, params);

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java?rev=1124219&r1=1124218&r2=1124219&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
Wed May 18 12:35:32 2011
@@ -76,8 +76,8 @@ public abstract class AbstractHttpServer
     private SessionInputBuffer inbuffer = null;
     private SessionOutputBuffer outbuffer = null;
     private EofSensor eofSensor = null;
-    private HttpMessageParser requestParser = null;
-    private HttpMessageWriter responseWriter = null;
+    private HttpMessageParser<HttpRequest> requestParser = null;
+    private HttpMessageWriter<HttpResponse> responseWriter = null;
     private HttpConnectionMetricsImpl metrics = null;
 
     /**
@@ -159,7 +159,7 @@ public abstract class AbstractHttpServer
      * @param params HTTP parameters.
      * @return HTTP message parser.
      */
-    protected HttpMessageParser createRequestParser(
+    protected HttpMessageParser<HttpRequest> createRequestParser(
             final SessionInputBuffer buffer,
             final HttpRequestFactory requestFactory,
             final HttpParams params) {
@@ -179,7 +179,7 @@ public abstract class AbstractHttpServer
      * @param params HTTP parameters
      * @return HTTP message writer
      */
-    protected HttpMessageWriter createResponseWriter(
+    protected HttpMessageWriter<HttpResponse> createResponseWriter(
             final SessionOutputBuffer buffer,
             final HttpParams params) {
         return new HttpResponseWriter(buffer, null, params);

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageParser.java?rev=1124219&r1=1124218&r2=1124219&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageParser.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageParser.java
Wed May 18 12:35:32 2011
@@ -57,7 +57,7 @@ import org.apache.http.util.CharArrayBuf
  *
  * @since 4.0
  */
-public abstract class AbstractMessageParser implements HttpMessageParser {
+public abstract class AbstractMessageParser<T extends HttpMessage> implements HttpMessageParser<T>
{
 
     private static final int HEAD_LINE    = 0;
     private static final int HEADERS      = 1;
@@ -69,7 +69,7 @@ public abstract class AbstractMessagePar
     protected final LineParser lineParser;
 
     private int state;
-    private HttpMessage message;
+    private T message;
 
     /**
      * Creates an instance of this class.
@@ -241,10 +241,10 @@ public abstract class AbstractMessagePar
      * @throws HttpException in case of HTTP protocol violation.
      * @throws ParseException in case of a parse error.
      */
-    protected abstract HttpMessage parseHead(SessionInputBuffer sessionBuffer)
+    protected abstract T parseHead(SessionInputBuffer sessionBuffer)
         throws IOException, HttpException, ParseException;
 
-    public HttpMessage parse() throws IOException, HttpException {
+    public T parse() throws IOException, HttpException {
         int st = this.state;
         switch (st) {
         case HEAD_LINE:
@@ -263,7 +263,7 @@ public abstract class AbstractMessagePar
                     this.lineParser,
                     this.headerLines);
             this.message.setHeaders(headers);
-            HttpMessage result = this.message;
+            T result = this.message;
             this.message = null;
             this.headerLines.clear();
             this.state = HEAD_LINE;

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageWriter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageWriter.java?rev=1124219&r1=1124218&r2=1124219&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageWriter.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageWriter.java
Wed May 18 12:35:32 2011
@@ -46,7 +46,7 @@ import org.apache.http.util.CharArrayBuf
  *
  * @since 4.0
  */
-public abstract class AbstractMessageWriter implements HttpMessageWriter {
+public abstract class AbstractMessageWriter<T extends HttpMessage> implements HttpMessageWriter<T>
{
 
     protected final SessionOutputBuffer sessionBuffer;
     protected final CharArrayBuffer lineBuf;
@@ -79,10 +79,9 @@ public abstract class AbstractMessageWri
      * @param message the message whose first line is to be written out.
      * @throws IOException in case of an I/O error.
      */
-    protected abstract void writeHeadLine(HttpMessage message) throws IOException;
+    protected abstract void writeHeadLine(T message) throws IOException;
 
-    public void write(
-            final HttpMessage message) throws IOException, HttpException {
+    public void write(final T message) throws IOException, HttpException {
         if (message == null) {
             throw new IllegalArgumentException("HTTP message may not be null");
         }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpRequestParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpRequestParser.java?rev=1124219&r1=1124218&r2=1124219&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpRequestParser.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpRequestParser.java
Wed May 18 12:35:32 2011
@@ -31,7 +31,6 @@ import java.io.IOException;
 
 import org.apache.http.ConnectionClosedException;
 import org.apache.http.HttpException;
-import org.apache.http.HttpMessage;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpRequestFactory;
 import org.apache.http.RequestLine;
@@ -55,7 +54,7 @@ import org.apache.http.util.CharArrayBuf
  *
  * @since 4.0
  */
-public class HttpRequestParser extends AbstractMessageParser {
+public class HttpRequestParser extends AbstractMessageParser<HttpRequest> {
 
     private final HttpRequestFactory requestFactory;
     private final CharArrayBuffer lineBuf;
@@ -83,7 +82,7 @@ public class HttpRequestParser extends A
     }
 
     @Override
-    protected HttpMessage parseHead(
+    protected HttpRequest parseHead(
             final SessionInputBuffer sessionBuffer)
         throws IOException, HttpException, ParseException {
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpRequestWriter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpRequestWriter.java?rev=1124219&r1=1124218&r2=1124219&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpRequestWriter.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpRequestWriter.java
Wed May 18 12:35:32 2011
@@ -29,7 +29,6 @@ package org.apache.http.impl.io;
 
 import java.io.IOException;
 
-import org.apache.http.HttpMessage;
 import org.apache.http.HttpRequest;
 import org.apache.http.io.SessionOutputBuffer;
 import org.apache.http.message.LineFormatter;
@@ -41,7 +40,7 @@ import org.apache.http.params.HttpParams
  *
  * @since 4.0
  */
-public class HttpRequestWriter extends AbstractMessageWriter {
+public class HttpRequestWriter extends AbstractMessageWriter<HttpRequest> {
 
     public HttpRequestWriter(final SessionOutputBuffer buffer,
                              final LineFormatter formatter,
@@ -50,11 +49,8 @@ public class HttpRequestWriter extends A
     }
 
     @Override
-    protected void writeHeadLine(final HttpMessage message)
-        throws IOException {
-
-        lineFormatter.formatRequestLine(this.lineBuf,
-                ((HttpRequest) message).getRequestLine());
+    protected void writeHeadLine(final HttpRequest message) throws IOException {
+        lineFormatter.formatRequestLine(this.lineBuf, message.getRequestLine());
         this.sessionBuffer.writeLine(this.lineBuf);
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpResponseParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpResponseParser.java?rev=1124219&r1=1124218&r2=1124219&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpResponseParser.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpResponseParser.java
Wed May 18 12:35:32 2011
@@ -30,7 +30,6 @@ package org.apache.http.impl.io;
 import java.io.IOException;
 
 import org.apache.http.HttpException;
-import org.apache.http.HttpMessage;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpResponseFactory;
 import org.apache.http.NoHttpResponseException;
@@ -55,7 +54,7 @@ import org.apache.http.util.CharArrayBuf
  *
  * @since 4.0
  */
-public class HttpResponseParser extends AbstractMessageParser {
+public class HttpResponseParser extends AbstractMessageParser<HttpResponse> {
 
     private final HttpResponseFactory responseFactory;
     private final CharArrayBuffer lineBuf;
@@ -83,7 +82,7 @@ public class HttpResponseParser extends 
     }
 
     @Override
-    protected HttpMessage parseHead(
+    protected HttpResponse parseHead(
             final SessionInputBuffer sessionBuffer)
         throws IOException, HttpException, ParseException {
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpResponseWriter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpResponseWriter.java?rev=1124219&r1=1124218&r2=1124219&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpResponseWriter.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpResponseWriter.java
Wed May 18 12:35:32 2011
@@ -29,7 +29,6 @@ package org.apache.http.impl.io;
 
 import java.io.IOException;
 
-import org.apache.http.HttpMessage;
 import org.apache.http.HttpResponse;
 import org.apache.http.io.SessionOutputBuffer;
 import org.apache.http.message.LineFormatter;
@@ -41,7 +40,7 @@ import org.apache.http.params.HttpParams
  *
  * @since 4.0
  */
-public class HttpResponseWriter extends AbstractMessageWriter {
+public class HttpResponseWriter extends AbstractMessageWriter<HttpResponse> {
 
     public HttpResponseWriter(final SessionOutputBuffer buffer,
                               final LineFormatter formatter,
@@ -50,11 +49,8 @@ public class HttpResponseWriter extends 
     }
 
     @Override
-    protected void writeHeadLine(final HttpMessage message)
-        throws IOException {
-
-        lineFormatter.formatStatusLine(this.lineBuf,
-                ((HttpResponse) message).getStatusLine());
+    protected void writeHeadLine(final HttpResponse message) throws IOException {
+        lineFormatter.formatStatusLine(this.lineBuf, message.getStatusLine());
         this.sessionBuffer.writeLine(this.lineBuf);
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/io/HttpMessageParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/io/HttpMessageParser.java?rev=1124219&r1=1124218&r2=1124219&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/io/HttpMessageParser.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/io/HttpMessageParser.java
Wed May 18 12:35:32 2011
@@ -38,7 +38,7 @@ import org.apache.http.HttpMessage;
  *
  * @since 4.0
  */
-public interface HttpMessageParser {
+public interface HttpMessageParser<T extends HttpMessage> {
 
     /**
      * Generates an instance of {@link HttpMessage} from the underlying data
@@ -48,7 +48,7 @@ public interface HttpMessageParser {
      * @throws IOException in case of an I/O error
      * @throws HttpException in case of HTTP protocol violation
      */
-    HttpMessage parse()
+    T parse()
         throws IOException, HttpException;
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/io/HttpMessageWriter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/io/HttpMessageWriter.java?rev=1124219&r1=1124218&r2=1124219&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/io/HttpMessageWriter.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/io/HttpMessageWriter.java
Wed May 18 12:35:32 2011
@@ -38,7 +38,7 @@ import org.apache.http.HttpMessage;
  *
  * @since 4.0
  */
-public interface HttpMessageWriter {
+public interface HttpMessageWriter<T extends HttpMessage> {
 
     /**
      * Serializes an instance of {@link HttpMessage} to the underlying data
@@ -48,7 +48,7 @@ public interface HttpMessageWriter {
      * @throws IOException in case of an I/O error
      * @throws HttpException in case of HTTP protocol violation
      */
-    void write(HttpMessage message)
+    void write(T message)
         throws IOException, HttpException;
 
 }



Mime
View raw message