[New] Implemented updating of strolch configuration from XML
This commit is contained in:
parent
a987928703
commit
f940aefed3
|
@ -41,7 +41,10 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.lang.management.*;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -471,19 +474,20 @@ public class StrolchAgent {
|
|||
File configPathF = runtimeConfig.getConfigPath();
|
||||
File dataPathF = runtimeConfig.getDataPath();
|
||||
File tempPathF = runtimeConfig.getTempPath();
|
||||
StrolchConfiguration newStrolchConfig = parseConfiguration(runtimeConfig.getEnvironment(), configPathF,
|
||||
StrolchConfiguration newConfig = parseConfiguration(runtimeConfig.getEnvironment(), configPathF,
|
||||
dataPathF, tempPathF);
|
||||
|
||||
Map<String, ComponentConfiguration> configurationsByComponent = new HashMap<>();
|
||||
for (String name : this.container.getComponentNames()) {
|
||||
ComponentConfiguration newComponentConfig = newConfig.getComponentConfiguration(name);
|
||||
StrolchComponent existingComponent = this.container.getComponentByName(name);
|
||||
Map<String, String> existingComponentConfig = existingComponent.getConfiguration().getAsMap();
|
||||
ComponentConfiguration newComponentConfig = newStrolchConfig.getComponentConfiguration(name);
|
||||
//existingComponent.getConfiguration().updateProperties(newComponentConfig.getAsMap());
|
||||
ComponentConfiguration existingComponentConfiguration = existingComponent.getConfiguration();
|
||||
existingComponentConfiguration.updateProperties(newComponentConfig.getAsMap());
|
||||
}
|
||||
|
||||
// this.strolchConfiguration = new StrolchConfiguration(newStrolchConfig.getRuntimeConfiguration(),
|
||||
// configurationsByComponent);
|
||||
RuntimeConfiguration newRuntimeConfiguration = newConfig.getRuntimeConfiguration();
|
||||
runtimeConfig.updateProperties(newRuntimeConfiguration.getAsMap());
|
||||
runtimeConfig.setLocale(newRuntimeConfiguration.getLocale());
|
||||
runtimeConfig.setSupportedLanguages(newRuntimeConfiguration.getSupportedLanguages());
|
||||
}
|
||||
|
||||
public JsonObject toJson() {
|
||||
|
|
|
@ -42,7 +42,7 @@ public abstract class AbstractionConfiguration {
|
|||
|
||||
public AbstractionConfiguration(String name, Map<String, String> configurationValues) {
|
||||
this.name = name;
|
||||
this.configurationValues = configurationValues;
|
||||
this.configurationValues = new HashMap<>(configurationValues);
|
||||
this.defaultValues = new HashMap<>();
|
||||
this.valueTypes = new HashMap<>();
|
||||
}
|
||||
|
@ -63,6 +63,11 @@ public abstract class AbstractionConfiguration {
|
|||
return new HashMap<>(this.configurationValues);
|
||||
}
|
||||
|
||||
public void updateProperties(Map<String, String> properties) {
|
||||
this.configurationValues.clear();
|
||||
this.configurationValues.putAll(properties);
|
||||
}
|
||||
|
||||
public boolean hasProperty(String key) {
|
||||
return this.configurationValues.containsKey(key);
|
||||
}
|
||||
|
|
|
@ -37,8 +37,8 @@ public class RuntimeConfiguration extends AbstractionConfiguration {
|
|||
private final File dataPath;
|
||||
private final File tempPath;
|
||||
|
||||
private final Locale locale;
|
||||
private final Set<SupportedLanguage> supportedLanguages;
|
||||
private Locale locale;
|
||||
private Set<SupportedLanguage> supportedLanguages;
|
||||
|
||||
public RuntimeConfiguration(String applicationName, String environment, Map<String, String> configurationValues,
|
||||
File configPathF, File dataPathF, File tempPathF, Set<SupportedLanguage> supportedLanguages) {
|
||||
|
@ -100,10 +100,18 @@ public class RuntimeConfiguration extends AbstractionConfiguration {
|
|||
return this.locale;
|
||||
}
|
||||
|
||||
public void setLocale(Locale locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public Set<SupportedLanguage> getSupportedLanguages() {
|
||||
return this.supportedLanguages;
|
||||
}
|
||||
|
||||
public void setSupportedLanguages(Set<SupportedLanguage> supportedLanguages) {
|
||||
this.supportedLanguages = supportedLanguages;
|
||||
}
|
||||
|
||||
public String getTimezone() {
|
||||
return getString(RuntimeConfiguration.PROP_TIMEZONE, System.getProperty("user.timezone"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue