Added property methods to HalContext
Former-commit-id: 2d2d1877ea892be4013fdb35394fe94eba91f58a
This commit is contained in:
parent
4370557958
commit
80d07bdbf2
3 changed files with 15 additions and 6 deletions
|
|
@ -12,7 +12,7 @@ public class HalContext {
|
|||
// Variables
|
||||
private static DBConnection db;
|
||||
|
||||
public static Properties conf;
|
||||
private static Properties fileConf;
|
||||
private static Properties defaultConf;
|
||||
|
||||
|
||||
|
|
@ -28,9 +28,9 @@ public class HalContext {
|
|||
public static void initialize(){
|
||||
try {
|
||||
// Read conf
|
||||
conf = new Properties(defaultConf);
|
||||
fileConf = new Properties(defaultConf);
|
||||
FileReader in = new FileReader(CONF_FILE);
|
||||
conf.load(in);
|
||||
fileConf.load(in);
|
||||
in.close();
|
||||
|
||||
// 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(){
|
||||
return db;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,8 +41,7 @@ public class PowerChallenge {
|
|||
daemon.initiate(daemonTimer);
|
||||
}
|
||||
|
||||
HttpServer http = new HttpServer(
|
||||
Integer.parseInt(HalContext.conf.getProperty("http_port")));
|
||||
HttpServer http = new HttpServer(HalContext.getIntegerProperty("http_port"));
|
||||
http.setDefaultPage(new HttpFilePage(FileUtil.find("web-resource/")));
|
||||
http.setPage("/", new PCOverviewHttpPage());
|
||||
http.setPage("/configure", new PCConfigureHttpPage());
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class DataSynchronizationDaemon extends ThreadedTCPNetworkServer implemen
|
|||
|
||||
|
||||
public DataSynchronizationDaemon() {
|
||||
super(Integer.parseInt(HalContext.conf.getProperty("sync_port")));
|
||||
super(HalContext.getIntegerProperty("sync_port"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue