diff src/org/eclipse/jetty/server/Connector.java @ 909:c60c1adfac3e

simplify connectors
author Franklin Schmidt <fschmidt@gmail.com>
date Sat, 08 Oct 2016 21:15:28 -0600
parents bc4e299de953
children 17f4fe8271de
line wrap: on
line diff
--- a/src/org/eclipse/jetty/server/Connector.java	Fri Oct 07 15:17:01 2016 -0600
+++ b/src/org/eclipse/jetty/server/Connector.java	Sat Oct 08 21:15:28 2016 -0600
@@ -22,6 +22,7 @@
 import java.net.InetAddress;
 import java.net.Socket;
 import java.net.UnknownHostException;
+import java.nio.channels.ServerSocketChannel;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.atomic.AtomicLong;
 
@@ -70,6 +71,9 @@
 
 	protected final HttpBuffersImpl _buffers = new HttpBuffersImpl();
 
+	// from child classes
+	protected transient ServerSocketChannel _acceptChannel;
+
 	public Connector(Server server,int port) {
 		this.server = server;
 		this.port = port;
@@ -81,26 +85,16 @@
 		_buffers.setResponseHeaderType(Type.INDIRECT);
 	}
 
-	/* ------------------------------------------------------------ */
-	/**
-	 */
 	public void setHost(String host)
 	{
 		_host = host;
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 */
 	public String getHost()
 	{
 		return _host;
 	}
 
-	/* ------------------------------------------------------------ */
-	/**
-	 * @return Returns the maxIdleTime.
-	 */
 	public int getMaxIdleTime()
 	{
 		return _maxIdleTime;
@@ -213,13 +207,9 @@
 		_soLingerTime = soLingerTime;
 	}
 
-	/* ------------------------------------------------------------ */
 	@Override
 	protected void doStart() throws Exception
 	{
-		// open listener port
-		open();
-
 		super.doStart();
 
 		// Start selector thread
@@ -274,19 +264,13 @@
 	{
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see org.eclipse.jetty.server.Connector#isConfidential(org.eclipse.jetty.server.Request)
-	 */
 	public boolean isConfidential(Request request)
 	{
 		return false;
 	}
 
-	/* ------------------------------------------------------------ */
 	protected abstract void accept() throws IOException, InterruptedException;
 
-	/* ------------------------------------------------------------ */
 	public void stopAccept(int acceptorID) throws Exception
 	{
 	}
@@ -376,19 +360,16 @@
 		return _buffers.getMaxBuffers();
 	}
 
-	/* ------------------------------------------------------------ */
 	@Override
 	public String toString()
 	{
 		return String.format("%s@%s:%d",
 				getClass().getSimpleName(),
 				getHost()==null?"0.0.0.0":getHost(),
-				getLocalPort()<=0 ? port : getLocalPort());
+				port);
 	}
 
-	/* ------------------------------------------------------------ */
-	/* ------------------------------------------------------------ */
-	/* ------------------------------------------------------------ */
+
 	private class Acceptor implements Runnable
 	{
 
@@ -400,7 +381,7 @@
 
 			try
 			{
-				while (isRunning() && getConnection() != null)
+				while (isRunning() && _acceptChannel != null)
 				{
 					try
 					{
@@ -435,21 +416,17 @@
 	public String getName()
 	{
 		if (_name == null)
-			_name = (getHost() == null?"0.0.0.0":getHost()) + ":" + (getLocalPort() <= 0?port:getLocalPort());
+			_name = (getHost() == null?"0.0.0.0":getHost()) + ":" + port;
 		return _name;
 	}
 
-	/* ------------------------------------------------------------ */
 	public final boolean isLowResources()
 	{
 		return server.isLowOnThreads();
 	}
 
 	// from old interface
-	public abstract void open() throws IOException;
 	public abstract void close() throws IOException;
-	public abstract int getLocalPort();
-	public abstract Object getConnection();
 
 
 	// from AbstractNIOConnector
@@ -470,4 +447,8 @@
 		_buffers.setRequestBufferType(direct?Type.DIRECT:Type.INDIRECT);
 		_buffers.setResponseBufferType(direct?Type.DIRECT:Type.INDIRECT);
 	}
+
+
+	// from child classes
+
 }