Merge "Fix raw references to Iterator"
[controller.git] / opendaylight / netconf / config-persister-impl / src / main / java / org / opendaylight / controller / netconf / persist / impl / osgi / PropertiesProviderBaseImpl.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.netconf.persist.impl.osgi;
9
10 import org.opendaylight.controller.config.persist.api.PropertiesProvider;
11 import org.osgi.framework.BundleContext;
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
14
15 public class PropertiesProviderBaseImpl implements PropertiesProvider {
16
17     private static final Logger LOG = LoggerFactory.getLogger(PropertiesProviderBaseImpl.class);
18     private final BundleContext bundleContext;
19
20     public PropertiesProviderBaseImpl(BundleContext bundleContext) {
21         this.bundleContext = bundleContext;
22     }
23
24     @Override
25     public String getProperty(String key) {
26         String fullKey = getFullKeyForReporting(key);
27         return getPropertyWithoutPrefix(fullKey);
28     }
29
30     public String getPropertyWithoutPrefix(String fullKey){
31         LOG.trace("Full key {}", fullKey);
32         return bundleContext.getProperty(fullKey);
33     }
34
35     public String getPrefix(){
36         return ConfigPersisterActivator.NETCONF_CONFIG_PERSISTER;
37     }
38
39     @Override
40     public String getFullKeyForReporting(String key) {
41         return getPrefix() + "." + key;
42     }
43 }