comparison src/org/eclipse/jetty/server/Server.java @ 886:0d876a03ab0b

add back Server.addConnector() - needed for ssl
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 04 Oct 2016 20:27:50 -0600
parents cb78ee27b0e0
children df84a1741687
comparison
equal deleted inserted replaced
885:150092cebf3e 886:0d876a03ab0b
20 20
21 import java.io.IOException; 21 import java.io.IOException;
22 import java.net.InetSocketAddress; 22 import java.net.InetSocketAddress;
23 import java.util.Collections; 23 import java.util.Collections;
24 import java.util.Enumeration; 24 import java.util.Enumeration;
25 import java.util.List;
26 import java.util.ArrayList;
25 import java.util.concurrent.LinkedBlockingQueue; 27 import java.util.concurrent.LinkedBlockingQueue;
26 import java.util.concurrent.ThreadPoolExecutor; 28 import java.util.concurrent.ThreadPoolExecutor;
27 import java.util.concurrent.TimeUnit; 29 import java.util.concurrent.TimeUnit;
28 30
29 import javax.servlet.ServletException; 31 import javax.servlet.ServletException;
59 61
60 public static final String version = "8"; 62 public static final String version = "8";
61 63
62 private final AttributesMap _attributes = new AttributesMap(); 64 private final AttributesMap _attributes = new AttributesMap();
63 public final ThreadPoolExecutor threadPool; 65 public final ThreadPoolExecutor threadPool;
64 public final Connector connector; 66 private final List<Connector> connectors = new ArrayList<Connector>();
65 67
66 68
67 /* ------------------------------------------------------------ */ 69 /* ------------------------------------------------------------ */
68 /** Convenience constructor 70 /** Convenience constructor
69 * Creates server and a {@link SelectChannelConnector} at the passed port. 71 * Creates server and a {@link SelectChannelConnector} at the passed port.
70 */ 72 */
71 public Server(int port) 73 public Server(int port)
72 { 74 {
73 setServer(this); 75 setServer(this);
74 76
75 connector = new SelectChannelConnector(); 77 Connector connector = new SelectChannelConnector();
76 connector.setPort(port); 78 connector.setPort(port);
77 connector.setServer(this); 79 connector.setServer(this);
80 connectors.add(connector);
78 81
79 threadPool = new ThreadPoolExecutor(256, 256, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()); 82 threadPool = new ThreadPoolExecutor(256, 256, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
80 } 83 }
81 84
85 // call before start
86 public void addConnector(Connector connector) {
87 connectors.add(connector);
88 }
82 89
83 /* ------------------------------------------------------------ */ 90 /* ------------------------------------------------------------ */
84 @Override 91 @Override
85 protected void doStart() throws Exception 92 protected void doStart() throws Exception
86 { 93 {
95 catch(Throwable e) 102 catch(Throwable e)
96 { 103 {
97 mex.add(e); 104 mex.add(e);
98 } 105 }
99 106
100 if (mex.size()==0) 107 if (mex.size()==0) {
101 { 108 for( Connector connector : connectors ) {
102 try{connector.start();} 109 try{connector.start();}
103 catch(Throwable e) 110 catch(Throwable e)
104 { 111 {
105 mex.add(e); 112 mex.add(e);
113 }
106 } 114 }
107 } 115 }
108 /* 116 /*
109 if (isDumpAfterStart()) 117 if (isDumpAfterStart())
110 dumpStdErr(); 118 dumpStdErr();
135 context.setShutdown(true); 143 context.setShutdown(true);
136 } 144 }
137 Thread.sleep(_graceful); 145 Thread.sleep(_graceful);
138 } 146 }
139 */ 147 */
140 try{connector.stop();}catch(Throwable e){mex.add(e);} 148 for( Connector connector : connectors ) {
149 try{connector.stop();}catch(Throwable e){mex.add(e);}
150 }
141 151
142 threadPool.shutdownNow(); 152 threadPool.shutdownNow();
143 153
144 try {super.doStop(); } catch(Throwable e) { mex.add(e);} 154 try {super.doStop(); } catch(Throwable e) { mex.add(e);}
145 155
271 /* ------------------------------------------------------------ */ 281 /* ------------------------------------------------------------ */
272 @Override 282 @Override
273 public void dump(Appendable out,String indent) throws IOException 283 public void dump(Appendable out,String indent) throws IOException
274 { 284 {
275 dumpThis(out); 285 dumpThis(out);
276 dump(out,indent,TypeUtil.asList(getHandlers()),getBeans(),Collections.singletonList(connector)); 286 dump(out,indent,TypeUtil.asList(getHandlers()),getBeans(),connectors);
277 } 287 }
278 288
279 289
280 /* ------------------------------------------------------------ */ 290 /* ------------------------------------------------------------ */
281 /* A handler that can be gracefully shutdown. 291 /* A handler that can be gracefully shutdown.