01: package CustomDNS.ZoneAuthenticator;
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.ZoneAuthenticator.Implementation;
12:
13: /*************************************************************************
14: * Manages our zone authenticator service.
15: *************************************************************************
16: * @see CustomDNS.ZoneAuthenticator.Implementation
17: */
18:
19: public class Server {
20:
21: /*********************************************************************
22: * Create a new zone authenticator service and register it.
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.ZoneAuthenticator";
34: Configuration config = Configuration.parseArguments(
35: appname, args);
36: Connection db = config.connectToDatabase();
37: String zone = config
38: .getProperty("customdns.authenticator.zone");
39: String connfile = config.getConnectionFile();
40:
41: // Connect to e-speak.
42: System.out.println(appname + ": Connecting to core.");
43: ESConnection core = new ESConnection(connfile);
44: ESServiceDescription desc = new ESServiceDescription();
45: desc.addAttribute("Name", zone);
46: ESServiceElement elem = new ESServiceElement(core, desc);
47: elem.setImplementation(new Implementation(db));
48: elem.register();
49: elem.start();
50: System.out.println(appname + ": Started service.");
51:
52: // Announce our status to net.espeak.util.SysLoader.
53: Task.setStatus(Task.STATUS_READY);
54: } catch (Exception e) {
55: System.err.println("CustomDNS.ZoneAuthenticator: "
56: + e.toString());
57: System.exit(1);
58: }
59:
60: // This is a really bad idea. Don't do it.
61: //System.exit(0);
62: }
63: }
|