*/
package org.opendaylight.lispflowmapping.implementation.config;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class ConfigIni {
+ protected static final Logger logger = LoggerFactory.getLogger(ConfigIni.class);
private boolean mappingOverwrite;
private boolean smr;
+ private static final String LISP_MAPPINGOVERWRITE = "lisp.mappingOverwrite";
+ private static final String LISP_SMR = "lisp.smr";
+
public ConfigIni() {
- initMappingOverwrite();
- initSmr();
+ Bundle b = FrameworkUtil.getBundle(this.getClass());
+ BundleContext context = null;
+ if (b != null) {
+ context = b.getBundleContext();
+ }
+
+ initMappingOverwrite(context);
+ initSmr(context);
}
- private void initMappingOverwrite() {
- String str = System.getProperty("lisp.mappingOverwrite");
- if (str != null) {
- if (str.trim().equalsIgnoreCase("false")) {
- this.mappingOverwrite = false;
+ private void initMappingOverwrite(BundleContext context) {
+ // set the default value first
+ this.mappingOverwrite = true;
+
+ String str = null;
+
+ if (context != null)
+ str = context.getProperty(LISP_MAPPINGOVERWRITE);
+
+ if (str == null) {
+ str = System.getProperty(LISP_MAPPINGOVERWRITE);
+ if (str == null) {
+ logger.debug("Configuration variable '{}' is unset. Setting to default value: true", LISP_MAPPINGOVERWRITE);
return;
}
}
- this.mappingOverwrite = true;
+
+ if (str.trim().equalsIgnoreCase("false")) {
+ this.mappingOverwrite = false;
+ logger.debug("Setting configuration variable '{}' to false", LISP_MAPPINGOVERWRITE);
+ } else {
+ logger.debug("Setting configuration variable '{}' to true", LISP_MAPPINGOVERWRITE);
+ }
}
- private void initSmr() {
- String str = System.getProperty("lisp.smr");
- if (str != null) {
- if (str.trim().equalsIgnoreCase("true")) {
- this.smr = true;
+ private void initSmr(BundleContext context) {
+ // set the default value first
+ this.smr = false;
+
+ String str = null;
+
+ if (context != null)
+ str = context.getProperty(LISP_SMR);
+
+ if (str == null) {
+ str = System.getProperty(LISP_SMR);
+ if (str == null) {
+ logger.debug("Configuration variable '{}' is unset. Setting to default value: false", LISP_SMR);
return;
}
}
- this.smr = false;
+
+ if (str.trim().equalsIgnoreCase("true")) {
+ this.smr = true;
+ logger.debug("Setting configuration variable '{}' to true", LISP_SMR);
+ } else {
+ logger.debug("Setting configuration variable '{}' to false", LISP_SMR);
+ }
}
public boolean mappingOverwriteIsSet() {