Changed properties defined by .config file to be read only
This commit is contained in:
parent
e57d62471b
commit
2dc35e212b
1 changed files with 12 additions and 25 deletions
|
|
@ -74,9 +74,6 @@ public class HalContext {
|
||||||
} else {
|
} else {
|
||||||
dbConf = db.exec("SELECT * FROM conf", new PropertiesSQLResult());
|
dbConf = db.exec("SELECT * FROM conf", new PropertiesSQLResult());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
@ -90,7 +87,6 @@ public class HalContext {
|
||||||
map.putAll(dbConf);
|
map.putAll(dbConf);
|
||||||
map.putAll(fileConf);
|
map.putAll(fileConf);
|
||||||
return map;
|
return map;
|
||||||
|
|
||||||
}
|
}
|
||||||
public static void registerProperty(String key) {
|
public static void registerProperty(String key) {
|
||||||
registeredConf.put(key, "");
|
registeredConf.put(key, "");
|
||||||
|
|
@ -100,41 +96,33 @@ public class HalContext {
|
||||||
return !ObjectUtil.isEmpty(getStringProperty(key));
|
return !ObjectUtil.isEmpty(getStringProperty(key));
|
||||||
}
|
}
|
||||||
public static String getStringProperty(String key){
|
public static String getStringProperty(String key){
|
||||||
|
return getStringProperty(key, null);
|
||||||
|
}
|
||||||
|
public static String getStringProperty(String key, String defaultValue){
|
||||||
registerProperty(key);
|
registerProperty(key);
|
||||||
|
|
||||||
String value = null;
|
String value = null;
|
||||||
|
if (dbConf != null)
|
||||||
|
value = dbConf.getProperty(key);
|
||||||
if (fileConf != null)
|
if (fileConf != null)
|
||||||
value = fileConf.getProperty(key);
|
value = fileConf.getProperty(key);
|
||||||
if (dbConf != null && value == null)
|
return value != null ? value : defaultValue;
|
||||||
value = dbConf.getProperty(key);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
public static String getStringProperty(String key, String defaultValue){
|
|
||||||
if (!containsProperty(key))
|
|
||||||
return defaultValue;
|
|
||||||
return getStringProperty(key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getIntegerProperty(String key){
|
public static int getIntegerProperty(String key){
|
||||||
String value = getStringProperty(key);
|
return getIntegerProperty(key, 0);
|
||||||
|
|
||||||
if (getStringProperty(key) == null)
|
|
||||||
return 0;
|
|
||||||
return Integer.parseInt(value);
|
|
||||||
}
|
}
|
||||||
public static int getIntegerProperty(String key, int defaultValue){
|
public static int getIntegerProperty(String key, int defaultValue){
|
||||||
if (!containsProperty(key))
|
String value = getStringProperty(key);
|
||||||
return defaultValue;
|
return value != null ? getIntegerProperty(key) : defaultValue;
|
||||||
return getIntegerProperty(key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getBooleanProperty(String key) {
|
public static boolean getBooleanProperty(String key) {
|
||||||
return Boolean.parseBoolean(getStringProperty(key));
|
return getBooleanProperty(key, false);
|
||||||
}
|
}
|
||||||
public static boolean getBooleanProperty(String key, boolean defaultValue) {
|
public static boolean getBooleanProperty(String key, boolean defaultValue) {
|
||||||
if (!containsProperty(key))
|
String value = getStringProperty(key);
|
||||||
return defaultValue;
|
return value != null ? Boolean.parseBoolean(getStringProperty(key)) : defaultValue;
|
||||||
return getBooleanProperty(key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setProperty(String key, String value) {
|
public static void setProperty(String key, String value) {
|
||||||
|
|
@ -151,7 +139,6 @@ public class HalContext {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static DBConnection getDB(){
|
public static DBConnection getDB(){
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue