diff src/org/eclipse/jetty/server/nio/BlockingChannelConnector.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/nio/BlockingChannelConnector.java	Fri Oct 07 15:17:01 2016 -0600
+++ b/src/org/eclipse/jetty/server/nio/BlockingChannelConnector.java	Sat Oct 08 21:15:28 2016 -0600
@@ -60,7 +60,6 @@
 {
 	private static final Logger LOG = LoggerFactory.getLogger(BlockingChannelConnector.class);
 
-	private transient ServerSocketChannel _acceptChannel;
 	private final Set<BlockingChannelEndPoint> _endpoints = new ConcurrentHashMap<BlockingChannelEndPoint,Boolean>().newKeySet();
 
 
@@ -73,19 +72,18 @@
 		super(server,port);
 	}
 
-	/* ------------------------------------------------------------ */
-	public Object getConnection()
-	{
-		return _acceptChannel;
-	}
 
-	/* ------------------------------------------------------------ */
-	/**
-	 * @see org.eclipse.jetty.server.AbstractConnector#doStart()
-	 */
 	@Override
 	protected void doStart() throws Exception
 	{
+		// Create a new server socket and set to non blocking mode
+		_acceptChannel= ServerSocketChannel.open();
+		_acceptChannel.configureBlocking(true);
+
+		// Bind the server socket to the local host and port
+		InetSocketAddress addr = getHost()==null?new InetSocketAddress(port):new InetSocketAddress(getHost(),port);
+		_acceptChannel.bind(addr);
+
 		super.doStart();
 		server.threadPool.execute(new Runnable()
 		{
@@ -118,20 +116,6 @@
 
 	}
 
-
-	/* ------------------------------------------------------------ */
-	public void open() throws IOException
-	{
-		// Create a new server socket and set to non blocking mode
-		_acceptChannel= ServerSocketChannel.open();
-		_acceptChannel.configureBlocking(true);
-
-		// Bind the server socket to the local host and port
-		InetSocketAddress addr = getHost()==null?new InetSocketAddress(port):new InetSocketAddress(getHost(),port);
-		_acceptChannel.socket().bind(addr);
-	}
-
-	/* ------------------------------------------------------------ */
 	public void close() throws IOException
 	{
 		if (_acceptChannel != null)
@@ -139,21 +123,19 @@
 		_acceptChannel=null;
 	}
 
-	/* ------------------------------------------------------------ */
 	@Override
 	public void accept()
 		throws IOException, InterruptedException
 	{
 		SocketChannel channel = _acceptChannel.accept();
 		channel.configureBlocking(true);
-		Socket socket=channel.socket();
+		Socket socket = channel.socket();
 		configure(socket);
 
 		BlockingChannelEndPoint connection=new BlockingChannelEndPoint(channel);
 		connection.dispatch();
 	}
 
-	/* ------------------------------------------------------------------------------- */
 	@Override
 	public void customize(EndPoint endpoint, Request request)
 		throws IOException
@@ -164,17 +146,6 @@
 	}
 
 
-	/* ------------------------------------------------------------------------------- */
-	public int getLocalPort()
-	{
-		if (_acceptChannel==null || !_acceptChannel.isOpen())
-			return -1;
-		return _acceptChannel.socket().getLocalPort();
-	}
-
-	/* ------------------------------------------------------------------------------- */
-	/* ------------------------------------------------------------------------------- */
-	/* ------------------------------------------------------------------------------- */
 	private class BlockingChannelEndPoint extends ChannelEndPoint implements Runnable, ConnectedEndPoint
 	{
 		private Connection _connection;