changeset 996:d9cfec64899c

simplify Connector
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 18 Oct 2016 21:22:53 -0600
parents 0eba8f555c19
children 7d28be82ab75
files src/org/eclipse/jetty/server/AbstractHttpConnection.java src/org/eclipse/jetty/server/Connector.java src/org/eclipse/jetty/server/Server.java src/org/eclipse/jetty/server/nio/BlockingChannelConnector.java src/org/eclipse/jetty/server/nio/SelectChannelConnector.java
diffstat 5 files changed, 46 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
diff -r 0eba8f555c19 -r d9cfec64899c src/org/eclipse/jetty/server/AbstractHttpConnection.java
--- a/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Tue Oct 18 18:38:05 2016 -0600
+++ b/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Tue Oct 18 21:22:53 2016 -0600
@@ -439,7 +439,7 @@
 
 	public final int getMaxIdleTime()
 	{
-		if (_connector.isLowResources() && _endp.getMaxIdleTime()==_connector.getMaxIdleTime())
+		if (_connector.server.isLowOnThreads() && _endp.getMaxIdleTime()==_connector.getMaxIdleTime())
 			return 0;
 		if (_endp.getMaxIdleTime()>0)
 			return _endp.getMaxIdleTime();
diff -r 0eba8f555c19 -r d9cfec64899c src/org/eclipse/jetty/server/Connector.java
--- a/src/org/eclipse/jetty/server/Connector.java	Tue Oct 18 18:38:05 2016 -0600
+++ b/src/org/eclipse/jetty/server/Connector.java	Tue Oct 18 21:22:53 2016 -0600
@@ -71,7 +71,7 @@
 	// from child classes
 	protected transient ServerSocketChannel _acceptChannel;
 
-	public Connector(Server server,int port) {
+	protected Connector(Server server,int port) {
 		this.server = server;
 		this.port = port;
 		server.connectors.add(this);
@@ -82,17 +82,17 @@
 		_buffers.setResponseHeaderType(Type.INDIRECT);
 	}
 
-	public void setHost(String host)
+	public final void setHost(String host)
 	{
 		_host = host;
 	}
 
-	public String getHost()
+	public final String getHost()
 	{
 		return _host;
 	}
 
-	public int getMaxIdleTime()
+	public final int getMaxIdleTime()
 	{
 		return _maxIdleTime;
 	}
@@ -124,11 +124,7 @@
 	}
 */
 
-	/* ------------------------------------------------------------ */
-	/**
-	 * @return Returns the soLingerTime.
-	 */
-	public int getSoLingerTime()
+	public final int getSoLingerTime()
 	{
 		return _soLingerTime;
 	}
@@ -138,7 +134,7 @@
 	 * @param soLingerTime
 	 *            The soLingerTime to set or -1 to disable.
 	 */
-	public void setSoLingerTime(int soLingerTime)
+	public final void setSoLingerTime(int soLingerTime)
 	{
 		_soLingerTime = soLingerTime;
 	}
@@ -184,9 +180,7 @@
 			socket.setSoLinger(false,0);
 	}
 
-	public void customize(EndPoint endpoint, Request request) throws IOException
-	{
-	}
+	public abstract void customize(EndPoint endpoint, Request request) throws IOException;
 
 	public boolean isConfidential()
 	{
@@ -195,91 +189,104 @@
 
 	protected abstract void accept() throws IOException, InterruptedException;
 
-	public void stopAccept(int acceptorID) throws Exception
-	{
-	}
-
-	public int getRequestBufferSize()
+	@Override
+	public final int getRequestBufferSize()
 	{
 		return _buffers.getRequestBufferSize();
 	}
 
-	public void setRequestBufferSize(int requestBufferSize)
+	@Override
+	public final void setRequestBufferSize(int requestBufferSize)
 	{
 		_buffers.setRequestBufferSize(requestBufferSize);
 	}
 
-	public int getRequestHeaderSize()
+	@Override
+	public final int getRequestHeaderSize()
 	{
 		return _buffers.getRequestHeaderSize();
 	}
 
-	public void setRequestHeaderSize(int requestHeaderSize)
+	@Override
+	public final void setRequestHeaderSize(int requestHeaderSize)
 	{
 		_buffers.setRequestHeaderSize(requestHeaderSize);
 	}
 
-	public int getResponseBufferSize()
+	@Override
+	public final int getResponseBufferSize()
 	{
 		return _buffers.getResponseBufferSize();
 	}
 
-	public void setResponseBufferSize(int responseBufferSize)
+	@Override
+	public final void setResponseBufferSize(int responseBufferSize)
 	{
 		_buffers.setResponseBufferSize(responseBufferSize);
 	}
 
-	public int getResponseHeaderSize()
+	@Override
+	public final int getResponseHeaderSize()
 	{
 		return _buffers.getResponseHeaderSize();
 	}
 
-	public void setResponseHeaderSize(int responseHeaderSize)
+	@Override
+	public final void setResponseHeaderSize(int responseHeaderSize)
 	{
 		_buffers.setResponseHeaderSize(responseHeaderSize);
 	}
 
-	public Type getRequestBufferType()
+	@Override
+	public final Type getRequestBufferType()
 	{
 		return _buffers.getRequestBufferType();
 	}
 
-	public Type getRequestHeaderType()
+	@Override
+	public final Type getRequestHeaderType()
 	{
 		return _buffers.getRequestHeaderType();
 	}
 
-	public Type getResponseBufferType()
+	@Override
+	public final Type getResponseBufferType()
 	{
 		return _buffers.getResponseBufferType();
 	}
 
-	public Type getResponseHeaderType()
+	@Override
+	public final Type getResponseHeaderType()
 	{
 		return _buffers.getResponseHeaderType();
 	}
 
-	public void setRequestBuffers(Buffers requestBuffers)
+	@Override
+	public final void setRequestBuffers(Buffers requestBuffers)
 	{
 		_buffers.setRequestBuffers(requestBuffers);
 	}
 
-	public void setResponseBuffers(Buffers responseBuffers)
+	@Override
+	public final void setResponseBuffers(Buffers responseBuffers)
 	{
 		_buffers.setResponseBuffers(responseBuffers);
 	}
 
-	public Buffers getRequestBuffers()
+	@Override
+	public final Buffers getRequestBuffers()
 	{
 		return _buffers.getRequestBuffers();
 	}
 
-	public Buffers getResponseBuffers()
+	@Override
+	public final Buffers getResponseBuffers()
 	{
 		return _buffers.getResponseBuffers();
 	}
 
-	public int getMaxBuffers()
+	@Override
+	public final int getMaxBuffers()
 	{
 		return _buffers.getMaxBuffers();
 	}
@@ -294,6 +301,7 @@
 	}
 
 
+	@Override
 	public void run()
 	{
 		Thread current = Thread.currentThread();
@@ -333,23 +341,17 @@
 		}
 	}
 
-	public String getName()
+	public final String getName()
 	{
 		if (_name == null)
 			_name = (getHost() == null?"0.0.0.0":getHost()) + ":" + port;
 		return _name;
 	}
 
-	public final boolean isLowResources()
-	{
-		return server.isLowOnThreads();
-	}
-
 
 	// from AbstractNIOConnector
 
-	/* ------------------------------------------------------------------------------- */
-	public boolean getUseDirectBuffers()
+	public final boolean getUseDirectBuffers()
 	{
 		return getRequestBufferType()==Type.DIRECT;
 	}
@@ -359,13 +361,10 @@
 	 * @param direct If True (the default), the connector can use NIO direct buffers.
 	 * Some JVMs have memory management issues (bugs) with direct buffers.
 	 */
-	public void setUseDirectBuffers(boolean direct)
+	public final void setUseDirectBuffers(boolean direct)
 	{
 		_buffers.setRequestBufferType(direct?Type.DIRECT:Type.INDIRECT);
 		_buffers.setResponseBufferType(direct?Type.DIRECT:Type.INDIRECT);
 	}
 
-
-	// from child classes
-
 }
diff -r 0eba8f555c19 -r d9cfec64899c src/org/eclipse/jetty/server/Server.java
--- a/src/org/eclipse/jetty/server/Server.java	Tue Oct 18 18:38:05 2016 -0600
+++ b/src/org/eclipse/jetty/server/Server.java	Tue Oct 18 21:22:53 2016 -0600
@@ -161,11 +161,6 @@
 		threadPool.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
 	}
 */
-	@Override
-	public String toString()
-	{
-		return this.getClass().getName()+"@"+Integer.toHexString(hashCode());
-	}
 
 	@Override
 	public void dump(Appendable out,String indent) throws IOException
diff -r 0eba8f555c19 -r d9cfec64899c src/org/eclipse/jetty/server/nio/BlockingChannelConnector.java
--- a/src/org/eclipse/jetty/server/nio/BlockingChannelConnector.java	Tue Oct 18 18:38:05 2016 -0600
+++ b/src/org/eclipse/jetty/server/nio/BlockingChannelConnector.java	Tue Oct 18 21:22:53 2016 -0600
@@ -136,7 +136,6 @@
 	public void customize(EndPoint endpoint, Request request)
 		throws IOException
 	{
-		super.customize(endpoint, request);
 		endpoint.setMaxIdleTime(_maxIdleTime);
 		configure(endpoint.getChannel().socket());
 	}
diff -r 0eba8f555c19 -r d9cfec64899c src/org/eclipse/jetty/server/nio/SelectChannelConnector.java
--- a/src/org/eclipse/jetty/server/nio/SelectChannelConnector.java	Tue Oct 18 18:38:05 2016 -0600
+++ b/src/org/eclipse/jetty/server/nio/SelectChannelConnector.java	Tue Oct 18 21:22:53 2016 -0600
@@ -82,7 +82,6 @@
 	{
 		request.setTimeStamp(System.currentTimeMillis());
 		endpoint.setMaxIdleTime(_maxIdleTime);
-		super.customize(endpoint, request);
 	}
 
 	@Override