public class ConfigurationImpl implements org.onap.config.api.Configuration {
private static final String KEY_CANNOT_BE_NULL = "Key can't be null.";
- private static final ThreadLocal<String> tenant = ThreadLocal.withInitial(() -> Constants.DEFAULT_TENANT);
+
+ private static final ThreadLocal<String> TENANT = ThreadLocal.withInitial(() -> Constants.DEFAULT_TENANT);
+
+ private static final Object LOCK = new Object();
private static boolean instantiated = false;
public ConfigurationImpl() throws Exception {
+
+ synchronized (LOCK) {
+ init();
+ }
+ }
+
+ private void init() throws Exception {
+
if (instantiated || !CliConfigurationImpl.class.isAssignableFrom(this.getClass())) {
throw new RuntimeException("Illegal access to configuration.");
}
+
Map<String, AggregateConfiguration> moduleConfigStore = new HashMap<>();
List<URL> classpathResources = ConfigurationUtils.getAllClassPathResources();
Predicate<URL> predicate = ConfigurationUtils::isConfig;
}
}
}
+
populateFinalConfigurationIncrementally(moduleConfigStore);
String nodeConfigLocation = System.getProperty("node.config.location");
if (nodeConfigLocation != null && nodeConfigLocation.trim().length() > 0) {
}
}
}
+
instantiated = true;
}
@Override
public <T> Map<String, T> populateMap(String tenantId, String namespace, String key, Class<T> clazz) {
+
if (tenantId == null || tenantId.trim().length() == 0) {
- tenantId = tenant.get();
+ tenantId = TENANT.get();
} else {
tenantId = tenantId.toUpperCase();
}
@Override
public Map generateMap(String tenantId, String namespace, String key) {
+
if (tenantId == null || tenantId.trim().length() == 0) {
- tenantId = tenant.get();
+ tenantId = TENANT.get();
} else {
tenantId = tenantId.toUpperCase();
}
}
if (tenant == null || tenant.trim().length() == 0) {
- tenant = ConfigurationImpl.tenant.get();
+ tenant = TENANT.get();
} else {
tenant = tenant.toUpperCase();
}