use of org.apache.karaf.features.ConfigInfo in project karaf by apache.
the class FeatureConfigInstaller method installFeatureConfigs.
public void installFeatureConfigs(Feature feature) throws IOException, InvalidSyntaxException {
for (ConfigInfo config : feature.getConfigurations()) {
TypedProperties props = new TypedProperties();
// trim lines
String val = config.getValue();
if (config.isExternal()) {
props.load(new URL(val));
} else {
props.load(new StringReader(val));
}
String[] pid = parsePid(config.getName());
Configuration cfg = findExistingConfiguration(configAdmin, pid[0], pid[1]);
if (cfg == null) {
Dictionary<String, Object> cfgProps = convertToDict(props);
cfg = createConfiguration(configAdmin, pid[0], pid[1]);
String key = createConfigurationKey(pid[0], pid[1]);
cfgProps.put(CONFIG_KEY, key);
cfg.update(cfgProps);
try {
updateStorage(pid[0], pid[1], props, false);
} catch (Exception e) {
LOGGER.warn("Can't update cfg file", e);
}
} else if (config.isAppend()) {
boolean update = false;
Dictionary<String, Object> properties = cfg.getProperties();
for (String key : props.keySet()) {
if (properties.get(key) == null) {
properties.put(key, props.get(key));
update = true;
}
}
if (update) {
cfg.update(properties);
try {
updateStorage(pid[0], pid[1], props, true);
} catch (Exception e) {
LOGGER.warn("Can't update cfg file", e);
}
}
}
}
for (ConfigFileInfo configFile : feature.getConfigurationFiles()) {
installConfigurationFile(configFile.getLocation(), configFile.getFinalname(), configFile.isOverride());
}
}
use of org.apache.karaf.features.ConfigInfo in project karaf by apache.
the class JmxFeature method getConfigList.
static TabularData getConfigList(List<ConfigInfo> config) throws OpenDataException {
TabularDataSupport table = new TabularDataSupport(FEATURE_CONFIG_TABLE);
for (ConfigInfo configInfo : config) {
String[] itemNames = FeaturesServiceMBean.FEATURE_CONFIG;
Object[] itemValues = { configInfo.getName(), getConfigElementTable(configInfo.getProperties()), new Boolean(configInfo.isAppend()) };
CompositeData configComposite = new CompositeDataSupport(FEATURE_CONFIG, itemNames, itemValues);
table.put(configComposite);
}
return table;
}
Aggregations