📄 tornado.java
字号:
// $Id: Tornado.java,v 1.29 2001/01/25 02:06:24 nconway Exp $
package tornado;
import java.net.*;
import java.io.*;
public class Tornado {
private final ServerPool serverPool;
private final ThreadManager threadManager;
/** Interface to the config file.*/
public final static Configuration config = new Configuration(
new File("/home/nconway/tornado/conf/tornado-conf.xml"));
/** Interface to the logging subsystem.*/
public final static Logger log = new Logger();
/** Looks up the MIME type for a specified file extension.*/
public final static MIMEDictionary mime =
new MIMEDictionary(config.getMimeTypes());
/** Constructs a server with the specified options. The server
* is prepared for production state, but it is fully started:
* we start <code>ServerThread</code>s, but don't bind to
* a local port. It is passed the command-line arguments
* specified, and it processes these.
* @see #start()
*/
public Tornado(String[] args) {
serverPool = new ServerPool(config.getStartThreads());
threadManager = new ThreadManager(serverPool);
}
/** Bootup the server from the console interface. This is very
* simple - it just creates a new instance of <code>Tornado</code>
* and starts it.
* @see #Tornado(String[])
*/
public static void main(String[] args) {
Tornado self = new Tornado(args);
self.execute();
}
public void execute() {
int[] ports = Tornado.config.getPorts();
for (int i = 0; i < ports.length; ++i) {
Thread t = new ListenThread(serverPool, ports[i]);
t.start();
}
System.out.println("Tornado is ready to accept connections");
threadManager.run();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -