/*
- * Copyright (c) 2014, 2015 Red Hat, Inc. and others. All rights reserved.
+ * Copyright (c) 2014, 2016 Red Hat, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
package org.opendaylight.ovsdb.utils.config;
+import java.util.HashMap;
+import java.util.Map;
+
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
public final class ConfigProperties {
+ private static final Map<String, String> OVERRIDES = new HashMap<>();
+
private ConfigProperties() {
// empty
}
}
public static String getProperty(Class<?> classParam, final String propertyStr, final String defaultValue) {
- String value = null;
+ String value = ConfigProperties.OVERRIDES.get(propertyStr);
+ if (value != null) {
+ return value;
+ }
+
Bundle bundle = FrameworkUtil.getBundle(classParam);
if (bundle != null) {
if (value == null) {
value = System.getProperty(propertyStr, defaultValue);
}
+
+ if (value == null) {
+ System.err.println("ConfigProperties missing a value for " + propertyStr);
+ }
+
return value;
}
+
+ public static void overrideProperty(String property, String value) {
+ ConfigProperties.OVERRIDES.put(property, value);
+ }
}