2 * Copyright (c) 2014, 2016 Red Hat, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.ovsdb.utils.config;
11 import java.util.HashMap;
14 import org.osgi.framework.Bundle;
15 import org.osgi.framework.BundleContext;
16 import org.osgi.framework.FrameworkUtil;
18 public final class ConfigProperties {
20 private static final Map<String, String> OVERRIDES = new HashMap<>();
22 private ConfigProperties() {
26 public static String getProperty(Class<?> classParam, final String propertyStr) {
27 return getProperty(classParam, propertyStr, null);
30 public static String getProperty(Class<?> classParam, final String propertyStr, final String defaultValue) {
31 String value = ConfigProperties.OVERRIDES.get(propertyStr);
36 Bundle bundle = FrameworkUtil.getBundle(classParam);
39 BundleContext bundleContext = bundle.getBundleContext();
40 if (bundleContext != null) {
41 value = bundleContext.getProperty(propertyStr);
45 value = System.getProperty(propertyStr, defaultValue);
49 System.err.println("ConfigProperties missing a value for " + propertyStr);
55 public static void overrideProperty(String property, String value) {
56 ConfigProperties.OVERRIDES.put(property, value);