01: package CustomDNS.ZoneController;
02:
03: import java.lang.Exception;
04: import java.sql.Connection;
05:
06: import net.espeak.infra.cci.exception.*;
07: import net.espeak.jesi.*;
08: import net.espeak.util.Task;
09:
10: import CustomDNS.Configuration;
11: import CustomDNS.ZoneController.Implementation;
12:
13: /*************************************************************************
14: * Manages our zone controller service.
15: *************************************************************************
16: * @see CustomDNS.ZoneController.Implementation
17: */
18:
19: public class Server {
20:
21: /*********************************************************************
22: * Create a new zone contoller service and register it with e-speak.
23: *********************************************************************
24: * @param args Our command-line arguments. Pass an espeak connection
25: * properties file and customdns.prop.
26: * @see CustomDNS.Configuration
27: */
28:
29: public static void main(String[] args) {
30: try {
31: // Parse our command line arguments, and get the configuration
32: // information we'll be needing.
33: String appname = "CustomDNS.ZoneController";
34: Configuration config = Configuration.parseArguments(
35: appname, args);
36: Connection db = config.connectToDatabase();
37: String zone = config
38: .getProperty("customdns.controller.zone");
39: String connfile = config.getConnectionFile();
40:
41: // Connect to e-speak.
42: System.out.println("CustomDNS.ZoneController: "
43: + "Connecting to core.");
44: ESConnection core = new ESConnection(connfile);
45: ESServiceDescription desc = new ESServiceDescription();
46: desc.addAttribute("Name", zone);
47: ESServiceElement elem = new ESServiceElement(core, desc);
48: elem.setImplementation(new Implementation(db));
49: elem.register();
50: elem.start();
51: System.out
52: .println("CustomDNS.ZoneController: Started service.");
53:
54: // Announce our status to net.espeak.util.SysLoader.
55: Task.setStatus(Task.STATUS_READY);
56: } catch (Exception e) {
57: System.err.println("CustomDNS.ZoneController: "
58: + e.toString());
59: System.exit(1);
60: }
61:
62: // This is a really bad idea. Don't do it.
63: //System.exit(0);
64: }
65:
66: }
|