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