comparison src/org/eclipse/jetty/server/Server.java @ 879:a3775d0c6985

remove ShutdownThread
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 04 Oct 2016 15:55:02 -0600
parents 5f8a242392da
children 00b3bd6e0ada
comparison
equal deleted inserted replaced
878:5f8a242392da 879:a3775d0c6985
42 import org.eclipse.jetty.util.URIUtil; 42 import org.eclipse.jetty.util.URIUtil;
43 import org.eclipse.jetty.util.component.Destroyable; 43 import org.eclipse.jetty.util.component.Destroyable;
44 import org.eclipse.jetty.util.component.LifeCycle; 44 import org.eclipse.jetty.util.component.LifeCycle;
45 import org.slf4j.Logger; 45 import org.slf4j.Logger;
46 import org.slf4j.LoggerFactory; 46 import org.slf4j.LoggerFactory;
47 import org.eclipse.jetty.util.thread.ShutdownThread;
48 47
49 /* ------------------------------------------------------------ */ 48 /* ------------------------------------------------------------ */
50 /** Jetty HTTP Servlet Server. 49 /** Jetty HTTP Servlet Server.
51 * This class is the main class for the Jetty HTTP Servlet server. 50 * This class is the main class for the Jetty HTTP Servlet server.
52 * It aggregates Connectors (HTTP request receivers) and request Handlers. 51 * It aggregates Connectors (HTTP request receivers) and request Handlers.
63 62
64 private final AttributesMap _attributes = new AttributesMap(); 63 private final AttributesMap _attributes = new AttributesMap();
65 public final ThreadPoolExecutor threadPool; 64 public final ThreadPoolExecutor threadPool;
66 public final Connector connector; 65 public final Connector connector;
67 private int _graceful=0; 66 private int _graceful=0;
68 private boolean _stopAtShutdown;
69 private boolean _dumpAfterStart=false; 67 private boolean _dumpAfterStart=false;
70 private boolean _dumpBeforeStop=false; 68 private boolean _dumpBeforeStop=false;
71 private boolean _uncheckedPrintWriter=false; 69 private boolean _uncheckedPrintWriter=false;
72 70
73 71
91 public static String getVersion() 89 public static String getVersion()
92 { 90 {
93 return __version; 91 return __version;
94 } 92 }
95 93
96 /* ------------------------------------------------------------ */
97 public boolean getStopAtShutdown()
98 {
99 return _stopAtShutdown;
100 }
101
102 /* ------------------------------------------------------------ */
103 public void setStopAtShutdown(boolean stop)
104 {
105 //if we now want to stop
106 if (stop)
107 {
108 //and we weren't stopping before
109 if (!_stopAtShutdown)
110 {
111 //only register to stop if we're already started (otherwise we'll do it in doStart())
112 if (isStarted())
113 ShutdownThread.register(this);
114 }
115 }
116 else
117 ShutdownThread.deregister(this);
118
119 _stopAtShutdown=stop;
120 }
121
122 /** 94 /**
123 * @return true if {@link #dumpStdErr()} is called after starting 95 * @return true if {@link #dumpStdErr()} is called after starting
124 */ 96 */
125 public boolean isDumpAfterStart() 97 public boolean isDumpAfterStart()
126 { 98 {
155 127
156 /* ------------------------------------------------------------ */ 128 /* ------------------------------------------------------------ */
157 @Override 129 @Override
158 protected void doStart() throws Exception 130 protected void doStart() throws Exception
159 { 131 {
160 if (getStopAtShutdown())
161 {
162 ShutdownThread.register(this);
163 }
164
165 ShutdownMonitor.getInstance().start(); // initialize
166
167 LOG.info("jetty-"+__version); 132 LOG.info("jetty-"+__version);
168 HttpGenerator.setServerVersion(__version); 133 HttpGenerator.setServerVersion(__version);
169 134
170 MultiException mex=new MultiException(); 135 MultiException mex=new MultiException();
171 136
222 threadPool.shutdownNow(); 187 threadPool.shutdownNow();
223 188
224 try {super.doStop(); } catch(Throwable e) { mex.add(e);} 189 try {super.doStop(); } catch(Throwable e) { mex.add(e);}
225 190
226 mex.ifExceptionThrow(); 191 mex.ifExceptionThrow();
227
228 if (getStopAtShutdown())
229 ShutdownThread.deregister(this);
230 } 192 }
231 193
232 /* ------------------------------------------------------------ */ 194 /* ------------------------------------------------------------ */
233 /* Handle a request from a connection. 195 /* Handle a request from a connection.
234 * Called to handle a request on the connection when either the header has been received, 196 * Called to handle a request on the connection when either the header has been received,