01: package dalma.container;
02:
03: import java.io.File;
04: import java.io.FileInputStream;
05: import java.io.IOException;
06: import java.util.logging.Level;
07: import java.util.logging.LogManager;
08: import java.util.logging.Logger;
09:
10: /**
11: * Entry point to the dalma container.
12: *
13: * @author Kohsuke Kawaguchi
14: */
15: public class Main {
16: private static final Logger logger = Logger.getLogger(Main.class
17: .getName());
18:
19: // run it with -Dcom.sun.management.jmxremote=true to enable JMX monitoring
20: public static void main(String[] args) throws Exception {
21: File home = getHome();
22:
23: logger.info("Starting dalma container with DALMA_HOME=" + home);
24:
25: Container container = Container.create(home);
26:
27: Thread.currentThread().suspend();
28:
29: //Thread.sleep(10*1000);
30: //logger.info("Terminating");
31: //container.stop();
32: //logger.info("done");
33: }
34:
35: /**
36: * Gets the dalma container home directory.
37: */
38: public static File getHome() {
39: String home = System.getProperty("DALMA_HOME");
40: if (home != null)
41: return new File(home);
42: return new File(".");
43: }
44:
45: public static File getConfigFile(String name) {
46: return new File(new File(getHome(), "conf"), name);
47: }
48:
49: static {
50: // configure the logger
51: configureLogger();
52: }
53:
54: private static void configureLogger() {
55: // this is the default
56: Logger.getLogger("dalma").setLevel(Level.ALL);
57:
58: // if the property file exists, load that configuration
59: File logProperties = getConfigFile("logging.properties");
60: if (logProperties.exists()) {
61: try {
62: FileInputStream in = new FileInputStream(logProperties);
63: try {
64: LogManager.getLogManager().readConfiguration(in);
65: } finally {
66: in.close();
67: }
68: } catch (IOException e) {
69: logger.log(Level.SEVERE, "Failed to read "
70: + logProperties, e);
71: }
72: }
73: }
74: }
|