01: // $Id: Tornado.java,v 1.29 2001/01/25 02:06:24 nconway Exp $
02: package tornado;
03:
04: import java.net.*;
05: import java.io.*;
06:
07: public class Tornado {
08: private final ServerPool serverPool;
09: private final ThreadManager threadManager;
10:
11: /** Interface to the config file.*/
12: public final static Configuration config = new Configuration(
13: new File("/home/nconway/tornado/conf/tornado-conf.xml"));
14: /** Interface to the logging subsystem.*/
15: public final static Logger log = new Logger();
16: /** Looks up the MIME type for a specified file extension.*/
17: public final static MIMEDictionary mime = new MIMEDictionary(config
18: .getMimeTypes());
19:
20: /** Constructs a server with the specified options. The server
21: * is prepared for production state, but it is fully started:
22: * we start <code>ServerThread</code>s, but don't bind to
23: * a local port. It is passed the command-line arguments
24: * specified, and it processes these.
25: * @see #start()
26: */
27: public Tornado(String[] args) {
28: serverPool = new ServerPool(config.getStartThreads());
29: threadManager = new ThreadManager(serverPool);
30: }
31:
32: /** Bootup the server from the console interface. This is very
33: * simple - it just creates a new instance of <code>Tornado</code>
34: * and starts it.
35: * @see #Tornado(String[])
36: */
37: public static void main(String[] args) {
38: Tornado self = new Tornado(args);
39: self.execute();
40: }
41:
42: public void execute() {
43: int[] ports = Tornado.config.getPorts();
44: for (int i = 0; i < ports.length; ++i) {
45: Thread t = new ListenThread(serverPool, ports[i]);
46: t.start();
47: }
48: System.out.println("Tornado is ready to accept connections");
49: threadManager.run();
50: }
51: }
|