changeset 982:dbecd7faa1f5

remove Generator
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 16 Oct 2016 21:40:27 -0600
parents f46de416e219
children 23ec25435b8c
files src/org/eclipse/jetty/http/AbstractGenerator.java src/org/eclipse/jetty/http/Generator.java src/org/eclipse/jetty/http/HttpGenerator.java src/org/eclipse/jetty/server/AbstractHttpConnection.java src/org/eclipse/jetty/server/BlockingHttpConnection.java src/org/eclipse/jetty/server/HttpOutput.java src/org/eclipse/jetty/server/Response.java
diffstat 7 files changed, 32 insertions(+), 118 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/eclipse/jetty/http/AbstractGenerator.java	Sun Oct 16 21:10:25 2016 -0600
+++ b/src/org/eclipse/jetty/http/AbstractGenerator.java	Sun Oct 16 21:40:27 2016 -0600
@@ -38,10 +38,13 @@
  * faster, but will consume more memory.   This option is just for testing and tuning.
  *
  */
-public abstract class AbstractGenerator implements Generator
+public abstract class AbstractGenerator
 {
 	private static final Logger LOG = LoggerFactory.getLogger(AbstractGenerator.class);
 
+	public static final boolean LAST=true;
+	public static final boolean MORE=false;
+
 	// states
 	public final static int STATE_HEADER = 0;
 	public final static int STATE_CONTENT = 2;
@@ -90,6 +93,19 @@
 		this._endp = io;
 	}
 
+	/* ------------------------------------------------------------ */
+	/**
+	 * Add content.
+	 * 
+	 * @param content
+	 * @param last
+	 * @throws IllegalArgumentException if <code>content</code> is {@link Buffer#isImmutable immutable}.
+	 * @throws IllegalStateException If the request is not expecting any more content,
+	 *   or if the buffers are full and cannot be flushed.
+	 * @throws IOException if there is a problem flushing the buffers.
+	 */
+	public abstract void addContent(Buffer content, boolean last) throws IOException;
+
 	/* ------------------------------------------------------------------------------- */
 	public abstract boolean isRequest();
 
@@ -275,16 +291,11 @@
 			_noContent=true;
 	}
 
-	/* ------------------------------------------------------------ */
 	public int getVersion()
 	{
 		return _version;
 	}
 
-	/* ------------------------------------------------------------ */
-	/**
-	 * @see org.eclipse.jetty.http.Generator#setDate(org.eclipse.jetty.io.Buffer)
-	 */
 	public void setDate(Buffer timeStampBuffer)
 	{
 		_date=timeStampBuffer;
@@ -462,12 +473,12 @@
 			if (content != null)
 			{
 				completeHeader(null, false);
-				addContent(new View(new ByteArrayBuffer(content)), Generator.LAST);
+				addContent(new View(new ByteArrayBuffer(content)), LAST);
 			}
 			else if (code>=400)
 			{
 				completeHeader(null, false);
-				addContent(new View(new ByteArrayBuffer("Error: "+(reason==null?(""+code):reason))), Generator.LAST);
+				addContent(new View(new ByteArrayBuffer("Error: "+(reason==null?(""+code):reason))), LAST);
 			}
 			else
 			{
--- a/src/org/eclipse/jetty/http/Generator.java	Sun Oct 16 21:10:25 2016 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-//
-//  ========================================================================
-//  Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
-//  ------------------------------------------------------------------------
-//  All rights reserved. This program and the accompanying materials
-//  are made available under the terms of the Eclipse Public License v1.0
-//  and Apache License v2.0 which accompanies this distribution.
-//
-//      The Eclipse Public License is available at
-//      http://www.eclipse.org/legal/epl-v10.html
-//
-//      The Apache License v2.0 is available at
-//      http://www.opensource.org/licenses/apache2.0.php
-//
-//  You may elect to redistribute this code under either of these licenses.
-//  ========================================================================
-//
-
-
-package org.eclipse.jetty.http;
-
-import java.io.IOException;
-
-import org.eclipse.jetty.io.Buffer;
-
-public interface Generator
-{
-	public static final boolean LAST=true;
-	public static final boolean MORE=false;
-
-	/* ------------------------------------------------------------ */
-	/**
-	 * Add content.
-	 * 
-	 * @param content
-	 * @param last
-	 * @throws IllegalArgumentException if <code>content</code> is {@link Buffer#isImmutable immutable}.
-	 * @throws IllegalStateException If the request is not expecting any more content,
-	 *   or if the buffers are full and cannot be flushed.
-	 * @throws IOException if there is a problem flushing the buffers.
-	 */
-	void addContent(Buffer content, boolean last) throws IOException;
-
-	void complete() throws IOException;
-
-	void completeHeader(HttpFields responseFields, boolean last) throws IOException;
-
-	int flushBuffer() throws IOException;
-
-	int getContentBufferSize();
-
-	long getContentWritten();
-
-	boolean isWritten();
-	
-	boolean isAllContentWritten();
-
-	void increaseContentBufferSize(int size);
-	
-	boolean isBufferFull();
-
-	boolean isCommitted();
-
-	boolean isComplete();
-
-	boolean isPersistent();
-
-	void reset();
-
-	void resetBuffer();
-	
-	void returnBuffers();
-
-	void sendError(int code, String reason, String content, boolean close) throws IOException;
-	
-	void setHead(boolean head);
-
-	void setRequest(String method, String uri);
-
-	void setResponse(int status, String reason);
-
- 
-	void setVersion(int version);
-
-	boolean isIdle();
-
-	void setContentLength(long length);
-	
-	void setPersistent(boolean persistent);
-
-	void setDate(Buffer timeStampBuffer);
-	
-
-}
--- a/src/org/eclipse/jetty/http/HttpGenerator.java	Sun Oct 16 21:10:25 2016 -0600
+++ b/src/org/eclipse/jetty/http/HttpGenerator.java	Sun Oct 16 21:40:27 2016 -0600
@@ -40,7 +40,7 @@
  *
  *
  */
-public class HttpGenerator extends AbstractGenerator
+public final class HttpGenerator extends AbstractGenerator
 {
 	private static final Logger LOG = LoggerFactory.getLogger(HttpGenerator.class);
 
--- a/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Sun Oct 16 21:10:25 2016 -0600
+++ b/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Sun Oct 16 21:40:27 2016 -0600
@@ -30,7 +30,6 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.eclipse.jetty.http.EncodedHttpURI;
-import org.eclipse.jetty.http.Generator;
 import org.eclipse.jetty.http.HttpBuffers;
 import org.eclipse.jetty.http.HttpException;
 import org.eclipse.jetty.http.HttpFields;
@@ -88,7 +87,7 @@
  * </p>
  *
  */
-public abstract class AbstractHttpConnection  extends AbstractConnection
+public abstract class AbstractHttpConnection extends AbstractConnection
 {
 	private static final Logger LOG = LoggerFactory.getLogger(AbstractHttpConnection.class);
 
@@ -384,7 +383,7 @@
 				_response.reset();
 				_generator.reset();
 				_generator.setResponse(HttpStatus.INTERNAL_SERVER_ERROR_500,null);
-				_generator.completeHeader(_responseFields,Generator.LAST);
+				_generator.completeHeader(_responseFields,HttpGenerator.LAST);
 				_generator.complete();
 				throw new HttpException(HttpStatus.INTERNAL_SERVER_ERROR_500);
 			}
@@ -401,7 +400,7 @@
 			_generator.setResponse(_response.getStatus(), _response.getReason());
 			try
 			{
-				_generator.completeHeader(_responseFields, Generator.LAST);
+				_generator.completeHeader(_responseFields, HttpGenerator.LAST);
 			}
 			catch(RuntimeException e)
 			{
@@ -411,7 +410,7 @@
 				_response.reset();
 				_generator.reset();
 				_generator.setResponse(HttpStatus.INTERNAL_SERVER_ERROR_500,null);
-				_generator.completeHeader(_responseFields,Generator.LAST);
+				_generator.completeHeader(_responseFields,HttpGenerator.LAST);
 				_generator.complete();
 				throw new HttpException(HttpStatus.INTERNAL_SERVER_ERROR_500);
 			}
@@ -424,7 +423,7 @@
 	{
 		try
 		{
-			commitResponse(Generator.MORE);
+			commitResponse(HttpGenerator.MORE);
 			_generator.flushBuffer();
 		}
 		catch(IOException e)
@@ -734,7 +733,7 @@
 				return;
 
 			if (!super._generator.isCommitted())
-				commitResponse(Generator.LAST);
+				commitResponse(HttpGenerator.LAST);
 			else
 				flushResponse();
 
@@ -750,7 +749,7 @@
 		public void flush() throws IOException
 		{
 			if (!super._generator.isCommitted())
-				commitResponse(Generator.MORE);
+				commitResponse(HttpGenerator.MORE);
 			super.flush();
 		}
 
@@ -792,8 +791,8 @@
 			// Process content.
 			if (content instanceof Buffer)
 			{
-				super._generator.addContent((Buffer) content, Generator.LAST);
-				commitResponse(Generator.LAST);
+				super._generator.addContent((Buffer) content, HttpGenerator.LAST);
+				commitResponse(HttpGenerator.LAST);
 			}
 			else if (content instanceof InputStream)
 			{
--- a/src/org/eclipse/jetty/server/BlockingHttpConnection.java	Sun Oct 16 21:10:25 2016 -0600
+++ b/src/org/eclipse/jetty/server/BlockingHttpConnection.java	Sun Oct 16 21:40:27 2016 -0600
@@ -20,7 +20,6 @@
 
 import java.io.IOException;
 
-import org.eclipse.jetty.http.Generator;
 import org.eclipse.jetty.http.HttpException;
 import org.eclipse.jetty.http.HttpStatus;
 import org.eclipse.jetty.io.EndPoint;
--- a/src/org/eclipse/jetty/server/HttpOutput.java	Sun Oct 16 21:10:25 2016 -0600
+++ b/src/org/eclipse/jetty/server/HttpOutput.java	Sun Oct 16 21:40:27 2016 -0600
@@ -24,7 +24,7 @@
 import javax.servlet.ServletOutputStream;
 
 import org.eclipse.jetty.http.AbstractGenerator;
-import org.eclipse.jetty.http.Generator;
+import org.eclipse.jetty.http.HttpGenerator;
 import org.eclipse.jetty.io.Buffer;
 import org.eclipse.jetty.io.ByteArrayBuffer;
 import org.eclipse.jetty.io.EofException;
@@ -152,7 +152,7 @@
 		}
 
 		// Add the _content
-		_generator.addContent(buffer, Generator.MORE);
+		_generator.addContent(buffer, HttpGenerator.MORE);
 
 		// Have to flush and complete headers?
 		
@@ -162,7 +162,7 @@
 			close();
 		} 
 		else if (_generator.isBufferFull())
-			_connection.commitResponse(Generator.MORE);
+			_connection.commitResponse(HttpGenerator.MORE);
 
 		// Block until our buffer is free
 		while (buffer.length() > 0 && _generator.isOpen())
--- a/src/org/eclipse/jetty/server/Response.java	Sun Oct 16 21:10:25 2016 -0600
+++ b/src/org/eclipse/jetty/server/Response.java	Sun Oct 16 21:40:27 2016 -0600
@@ -36,7 +36,6 @@
 
 import org.eclipse.jetty.http.HttpCookie;
 import org.eclipse.jetty.http.HttpFields;
-import org.eclipse.jetty.http.HttpGenerator;
 import org.eclipse.jetty.http.HttpHeaderValues;
 import org.eclipse.jetty.http.HttpHeaders;
 import org.eclipse.jetty.http.HttpSchemes;