diff src/org/eclipse/jetty/server/Connector.java @ 887:df84a1741687

make Connector reference to server explicit
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 04 Oct 2016 23:59:56 -0600
parents 150092cebf3e
children 1aa58272794f
line wrap: on
line diff
--- a/src/org/eclipse/jetty/server/Connector.java	Tue Oct 04 20:27:50 2016 -0600
+++ b/src/org/eclipse/jetty/server/Connector.java	Tue Oct 04 23:59:56 2016 -0600
@@ -59,9 +59,9 @@
 
 	private String _name;
 
-	private Server _server;
+	public final Server server;
 	private String _host;
-	private int _port = 0;
+	public final int port;
 	private String _integralScheme = HttpSchemes.HTTPS;
 	private int _integralPort = 0;
 	private String _confidentialScheme = HttpSchemes.HTTPS;
@@ -89,35 +89,14 @@
 
 	protected final HttpBuffersImpl _buffers = new HttpBuffersImpl();
 
-	/* ------------------------------------------------------------ */
-	/**
-	 */
-	public Connector()
-	{
+	public Connector(Server server,int port) {
+		this.server = server;
+		this.port = port;
+		server.connectors.add(this);
 		addBean(_buffers);
 	}
 
 	/* ------------------------------------------------------------ */
-	/*
-	 */
-	public Server getServer()
-	{
-		return _server;
-	}
-
-	/* ------------------------------------------------------------ */
-	public void setServer(Server server)
-	{
-		_server = server;
-	}
-
-	/* ------------------------------------------------------------ */
-	public ThreadPoolExecutor getThreadPool()
-	{
-		return _server.threadPool;
-	}
-
-	/* ------------------------------------------------------------ */
 	/**
 	 */
 	public void setHost(String host)
@@ -134,18 +113,6 @@
 	}
 
 	/* ------------------------------------------------------------ */
-	public void setPort(int port)
-	{
-		_port = port;
-	}
-
-	/* ------------------------------------------------------------ */
-	public int getPort()
-	{
-		return _port;
-	}
-
-	/* ------------------------------------------------------------ */
 	/**
 	 * @return Returns the maxIdleTime.
 	 */
@@ -284,9 +251,6 @@
 	@Override
 	protected void doStart() throws Exception
 	{
-		if (_server == null)
-			throw new IllegalStateException("No server");
-
 		// open listener port
 		open();
 
@@ -297,10 +261,10 @@
 		{
 			_acceptorThreads = new Thread[getAcceptors()];
 
-			ThreadPoolExecutor _threadPool = getThreadPool();
+			ThreadPoolExecutor _threadPool = server.threadPool;
 			for (int i = 0; i < _acceptorThreads.length; i++)
 				_threadPool.execute(new Acceptor(i));
-			if (_server.isLowOnThreads())
+			if (server.isLowOnThreads())
 				LOG.warn("insufficient threads configured for {}",this);
 		}
 
@@ -861,7 +825,7 @@
 		return String.format("%s@%s:%d",
 				getClass().getSimpleName(),
 				getHost()==null?"0.0.0.0":getHost(),
-				getLocalPort()<=0?getPort():getLocalPort());
+				getLocalPort()<=0 ? port : getLocalPort());
 	}
 
 	/* ------------------------------------------------------------ */
@@ -938,7 +902,7 @@
 	public String getName()
 	{
 		if (_name == null)
-			_name = (getHost() == null?"0.0.0.0":getHost()) + ":" + (getLocalPort() <= 0?getPort():getLocalPort());
+			_name = (getHost() == null?"0.0.0.0":getHost()) + ":" + (getLocalPort() <= 0?port:getLocalPort());
 		return _name;
 	}
 
@@ -1008,7 +972,7 @@
 	/* ------------------------------------------------------------ */
 	public final boolean isLowResources()
 	{
-		return _server.isLowOnThreads();
+		return server.isLowOnThreads();
 	}
 
 	/* ------------------------------------------------------------ */