completed setup for installation, fixed robustness problem.
[upnpmonitor] / monitor / src / main / java / org / wamblee / upnpmonitor / Main.java
1 package org.wamblee.upnpmonitor;
2
3 import java.io.File;
4 import java.io.FileInputStream;
5 import java.io.InputStream;
6 import java.util.Properties;
7 import java.util.logging.Logger;
8
9 public class Main {
10
11     private static final Logger LOGGER = Logger.getLogger(Main.class.getName());
12
13     public static void main(String[] aArgs) throws Exception {
14
15         String propertyFile = System
16             .getProperty("org.wamblee.upnpmonitor.propertyfile");
17         Properties props = new Properties();
18         InputStream is = new FileInputStream(new File(propertyFile));
19         props.load(is);
20         is.close();
21
22         Config config = Config.parse(props);
23         LOGGER.info("COnfiguration: " + config);
24
25         final Monitor monitor = new Monitor(config);
26
27         Runtime.getRuntime().addShutdownHook(new Thread() {
28             @Override
29             public void run() {
30                 System.out
31                     .println("Signal caught, terminating monitor and executing shutdown command");
32                 monitor.stop();
33             }
34         });
35
36         monitor.start();
37     }
38 }