⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tornado.java

📁 一个经典的java的web服务器的建立源代码
💻 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 + -