aboutsummaryrefslogtreecommitdiffstats
path: root/common/openecomp-common-configuration-management/openecomp-configuration-management-api/src/main/java/org/openecomp/config/api/ConfigurationManager.java
blob: ffa9255f2cf270698dce7425509d8e6216638d7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package org.openecomp.config.api;


import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Proxy;
import java.util.Collection;
import java.util.Map;
import java.util.ServiceLoader;

/**
 * The interface Configuration manager.
 */
public interface ConfigurationManager extends Configuration {

  /**
   * The constant config.
   */
  public static final Configuration config = lookup();

  /**
   * Lookup configuration.
   *
   * @return the configuration
   */
  public static Configuration lookup() {
    if (config == null) {
      ServiceLoader<ConfigurationManager> loader = ServiceLoader.load(ConfigurationManager.class);
      for (ConfigurationManager configuration : loader) {
        return (Configuration) Proxy.newProxyInstance(ConfigurationManager.class.getClassLoader(),
            new Class[]{Configuration.class}, (object, method, args) -> {
              try {
                return method.invoke(configuration, args);
              } catch (InvocationTargetException ite) {
                throw ite.getTargetException();
              }
            });
      }
    }
    return config;
  }

  /**
   * Gets configuration value.
   *
   * @param queryData the query data
   * @return the configuration value
   */
  public String getConfigurationValue(Map<String, Object> queryData);

  /**
   * Update configuration value.
   *
   * @param updateData the update data
   */
  public void updateConfigurationValue(Map<String, Object> updateData);

  /**
   * List configuration map.
   *
   * @param query the query
   * @return the map
   */
  public Map<String, String> listConfiguration(Map<String, Object> query);

  /**
   * Update configuration values boolean.
   *
   * @param tenant              the tenant
   * @param namespace           the namespace
   * @param configKeyValueStore the config key value store
   * @return the boolean
   */
  public boolean updateConfigurationValues(String tenant, String namespace,
                                           Map configKeyValueStore);

  /**
   * Gets tenants.
   *
   * @return the tenants
   */
  public Collection<String> getTenants();

  /**
   * Gets namespaces.
   *
   * @return the namespaces
   */
  public Collection<String> getNamespaces();

  /**
   * Gets keys.
   *
   * @param tenant    the tenant
   * @param namespace the namespace
   * @return the keys
   */
  public Collection<String> getKeys(String tenant, String namespace);
}