Added property methods to HalContext

Former-commit-id: 2d2d1877ea892be4013fdb35394fe94eba91f58a
This commit is contained in:
Ziver Koc 2015-12-07 21:56:52 +01:00
parent 4370557958
commit 80d07bdbf2
3 changed files with 15 additions and 6 deletions

View file

@ -12,7 +12,7 @@ public class HalContext {
// Variables // Variables
private static DBConnection db; private static DBConnection db;
public static Properties conf; private static Properties fileConf;
private static Properties defaultConf; private static Properties defaultConf;
@ -28,9 +28,9 @@ public class HalContext {
public static void initialize(){ public static void initialize(){
try { try {
// Read conf // Read conf
conf = new Properties(defaultConf); fileConf = new Properties(defaultConf);
FileReader in = new FileReader(CONF_FILE); FileReader in = new FileReader(CONF_FILE);
conf.load(in); fileConf.load(in);
in.close(); in.close();
// Init DB // Init DB
@ -41,6 +41,16 @@ public class HalContext {
} }
public static String getStringProperty(String key){
String value = fileConf.getProperty(key);
//if(value == null) // TODO: DB property
// value = dbConf.getProperty(key);
return value;
}
public static int getIntegerProperty(String key){
return Integer.parseInt(getStringProperty(key));
}
public static DBConnection getDB(){ public static DBConnection getDB(){
return db; return db;
} }

View file

@ -41,8 +41,7 @@ public class PowerChallenge {
daemon.initiate(daemonTimer); daemon.initiate(daemonTimer);
} }
HttpServer http = new HttpServer( HttpServer http = new HttpServer(HalContext.getIntegerProperty("http_port"));
Integer.parseInt(HalContext.conf.getProperty("http_port")));
http.setDefaultPage(new HttpFilePage(FileUtil.find("web-resource/"))); http.setDefaultPage(new HttpFilePage(FileUtil.find("web-resource/")));
http.setPage("/", new PCOverviewHttpPage()); http.setPage("/", new PCOverviewHttpPage());
http.setPage("/configure", new PCConfigureHttpPage()); http.setPage("/configure", new PCConfigureHttpPage());

View file

@ -24,7 +24,7 @@ public class DataSynchronizationDaemon extends ThreadedTCPNetworkServer implemen
public DataSynchronizationDaemon() { public DataSynchronizationDaemon() {
super(Integer.parseInt(HalContext.conf.getProperty("sync_port"))); super(HalContext.getIntegerProperty("sync_port"));
} }
@Override @Override