Rename packages from openecomp to onap.
[sdc.git] / common / onap-common-configuration-management / onap-configuration-management-api / src / main / java / org / onap / config / api / ConfigurationManager.java
1 package org.onap.config.api;
2
3
4 import java.lang.reflect.InvocationTargetException;
5 import java.lang.reflect.Proxy;
6 import java.util.Collection;
7 import java.util.Map;
8 import java.util.ServiceLoader;
9
10 /**
11  * The interface Configuration manager.
12  */
13 public interface ConfigurationManager extends Configuration {
14
15   /**
16    * The constant config.
17    */
18   public static final Configuration config = lookup();
19
20   /**
21    * Lookup configuration.
22    *
23    * @return the configuration
24    */
25   public static Configuration lookup() {
26     if (config == null) {
27       ServiceLoader<ConfigurationManager> loader = ServiceLoader.load(ConfigurationManager.class);
28       for (ConfigurationManager configuration : loader) {
29         return (Configuration) Proxy.newProxyInstance(ConfigurationManager.class.getClassLoader(),
30             new Class[]{Configuration.class}, (object, method, args) -> {
31               try {
32                 return method.invoke(configuration, args);
33               } catch (InvocationTargetException ite) {
34                 throw ite.getTargetException();
35               }
36             });
37       }
38     }
39     return config;
40   }
41
42   /**
43    * Gets configuration value.
44    *
45    * @param queryData the query data
46    * @return the configuration value
47    */
48   public String getConfigurationValue(Map<String, Object> queryData);
49
50   /**
51    * Update configuration value.
52    *
53    * @param updateData the update data
54    */
55   public void updateConfigurationValue(Map<String, Object> updateData);
56
57   /**
58    * List configuration map.
59    *
60    * @param query the query
61    * @return the map
62    */
63   public Map<String, String> listConfiguration(Map<String, Object> query);
64
65   /**
66    * Update configuration values boolean.
67    *
68    * @param tenant              the tenant
69    * @param namespace           the namespace
70    * @param configKeyValueStore the config key value store
71    * @return the boolean
72    */
73   public boolean updateConfigurationValues(String tenant, String namespace,
74                                            Map configKeyValueStore);
75
76   /**
77    * Gets tenants.
78    *
79    * @return the tenants
80    */
81   public Collection<String> getTenants();
82
83   /**
84    * Gets namespaces.
85    *
86    * @return the namespaces
87    */
88   public Collection<String> getNamespaces();
89
90   /**
91    * Gets keys.
92    *
93    * @param tenant    the tenant
94    * @param namespace the namespace
95    * @return the keys
96    */
97   public Collection<String> getKeys(String tenant, String namespace);
98 }