X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-persister-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fpersist%2Fimpl%2Fosgi%2FPropertiesProviderBaseImpl.java;fp=opendaylight%2Fconfig%2Fconfig-persister-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fpersist%2Fimpl%2Fosgi%2FPropertiesProviderBaseImpl.java;h=5ad31e878095f113d80bcbc081447a3040a0a3d7;hb=23fe9ca678ada6263fec5dd996f4025e4a32fcf5;hp=0000000000000000000000000000000000000000;hpb=071a641d7c12c0e6112d5ce0afe806b54f116ed2;p=controller.git diff --git a/opendaylight/config/config-persister-impl/src/main/java/org/opendaylight/controller/config/persist/impl/osgi/PropertiesProviderBaseImpl.java b/opendaylight/config/config-persister-impl/src/main/java/org/opendaylight/controller/config/persist/impl/osgi/PropertiesProviderBaseImpl.java new file mode 100644 index 0000000000..5ad31e8780 --- /dev/null +++ b/opendaylight/config/config-persister-impl/src/main/java/org/opendaylight/controller/config/persist/impl/osgi/PropertiesProviderBaseImpl.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015 Cisco Systems, 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, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.config.persist.impl.osgi; + +import org.opendaylight.controller.config.persist.api.PropertiesProvider; +import org.osgi.framework.BundleContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class PropertiesProviderBaseImpl implements PropertiesProvider { + + private static final Logger LOG = LoggerFactory.getLogger(PropertiesProviderBaseImpl.class); + private final BundleContext bundleContext; + + public PropertiesProviderBaseImpl(BundleContext bundleContext) { + this.bundleContext = bundleContext; + } + + @Override + public String getProperty(String key) { + String fullKey = getFullKeyForReporting(key); + return getPropertyWithoutPrefix(fullKey); + } + + public String getPropertyWithoutPrefix(String fullKey){ + LOG.trace("Full key {}", fullKey); + return bundleContext.getProperty(fullKey); + } + + public String getPrefix(){ + return ConfigPersisterActivator.NETCONF_CONFIG_PERSISTER; + } + + @Override + public String getFullKeyForReporting(String key) { + return getPrefix() + "." + key; + } +}