diff src/org/eclipse/jetty/server/Connector.java @ 1007:945568ee77ac

remove HttpBuffersImpl
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 23 Oct 2016 17:40:20 -0600
parents 58a9c4a42292
children b664624a4423
line wrap: on
line diff
--- a/src/org/eclipse/jetty/server/Connector.java	Sun Oct 23 17:21:20 2016 -0600
+++ b/src/org/eclipse/jetty/server/Connector.java	Sun Oct 23 17:40:20 2016 -0600
@@ -28,12 +28,8 @@
 
 import javax.servlet.ServletRequest;
 
-import org.eclipse.jetty.http.HttpBuffersImpl;
-import org.eclipse.jetty.http.HttpFields;
-import org.eclipse.jetty.http.HttpHeaders;
-import org.eclipse.jetty.http.HttpSchemes;
 import org.eclipse.jetty.io.Buffers;
-import org.eclipse.jetty.io.Buffers.Type;
+import org.eclipse.jetty.io.BuffersFactory;
 import org.eclipse.jetty.io.EndPoint;
 import org.eclipse.jetty.io.EofException;
 import org.eclipse.jetty.util.component.AggregateLifeCycle;
@@ -65,8 +61,6 @@
 	protected final int _maxIdleTime = 200000;
 	protected int _soLingerTime = -1;
 
-	protected final HttpBuffersImpl _buffers = new HttpBuffersImpl();
-
 	// from child classes
 	protected transient ServerSocketChannel _acceptChannel;
 
@@ -74,7 +68,6 @@
 		this.server = server;
 		this.port = port;
 		server.connectors.add(this);
-		addBean(_buffers);
 	}
 
 	public final void setHost(String host)
@@ -139,6 +132,8 @@
 		if (server.isLowOnThreads())
 			LOG.warn("insufficient threads configured for {}",this);
 
+		startBuffers();
+
 		LOG.info("Started {}",this);
 	}
 
@@ -156,6 +151,8 @@
 			LOG.warn("",e);
 		}
 
+		stopBuffers();
+
 		super.doStop();
 	}
 
@@ -236,22 +233,44 @@
 	}
 
 
-	// from AbstractNIOConnector
+
+	// from HttpBuffersImpl
 
-	public final boolean getUseDirectBuffers()
+	protected int _requestBufferSize = 16*1024;
+	protected int _requestHeaderSize = 6*1024;
+	private final int _responseBufferSize = 32*1024;
+	private final int _responseHeaderSize = 6*1024;
+	private final int _maxBuffers = 1024;
+	
+	protected Buffers.Type _requestBufferType = Buffers.Type.DIRECT;
+	protected Buffers.Type _responseBufferType = Buffers.Type.DIRECT;
+	
+	private Buffers _requestBuffers;
+	private Buffers _responseBuffers;
+
+	private void startBuffers()
+		throws Exception
 	{
-		return _buffers.getRequestBufferType()==Type.DIRECT;
+		_requestBuffers = BuffersFactory.newBuffers(Buffers.Type.INDIRECT,_requestHeaderSize,_requestBufferType,_requestBufferSize,_maxBuffers);
+		_responseBuffers = BuffersFactory.newBuffers(Buffers.Type.INDIRECT,_responseHeaderSize,_responseBufferType,_responseBufferSize,_maxBuffers);
+		super.doStart();
+	}
+	
+	private void stopBuffers()
+		throws Exception
+	{
+		_requestBuffers = null;
+		_responseBuffers = null;
 	}
 
-	/* ------------------------------------------------------------------------------- */
-	/**
-	 * @param direct If True (the default), the connector can use NIO direct buffers.
-	 * Some JVMs have memory management issues (bugs) with direct buffers.
-	 */
-	public final void setUseDirectBuffers(boolean direct)
+	public final Buffers getRequestBuffers()
 	{
-		_buffers.setRequestBufferType(direct?Type.DIRECT:Type.INDIRECT);
-		_buffers.setResponseBufferType(direct?Type.DIRECT:Type.INDIRECT);
+		return _requestBuffers;
+	}
+	
+	public final Buffers getResponseBuffers()
+	{
+		return _responseBuffers;
 	}
 
 }