Starts this server. If it is already started, does nothing. Note: Once the server is started, configuration-altering methods of the server and its virtual hosts must not be used. To modify the configuration, the server must first be stopped. @throws IOException if the server cannot begin accepting
()
| 2028 | * @throws IOException if the server cannot begin accepting connections |
| 2029 | */ |
| 2030 | public synchronized void start() throws IOException { |
| 2031 | if (serv != null) |
| 2032 | return; |
| 2033 | if (serverSocketFactory == null) // assign default server socket factory if needed |
| 2034 | serverSocketFactory = ServerSocketFactory.getDefault(); // plain sockets |
| 2035 | serv = createServerSocket(); |
| 2036 | if (executor == null) // assign default executor if needed |
| 2037 | executor = Executors.newCachedThreadPool(); // consumes no resources when idle |
| 2038 | // register all host aliases (which may have been modified) |
| 2039 | for (VirtualHost host : getVirtualHosts()) |
| 2040 | for (String alias : host.getAliases()) |
| 2041 | hosts.put(alias, host); |
| 2042 | // start handling incoming connections |
| 2043 | new SocketHandlerThread().start(); |
| 2044 | } |
| 2045 | |
| 2046 | /** |
| 2047 | * Stops this server. If it is already stopped, does nothing. |
no test coverage detected