use of org.apache.karaf.features.ConfigFileInfo 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.ConfigFileInfo in project karaf by apache.
the class KarServiceImpl method copyFeatureToJar.
private void copyFeatureToJar(JarOutputStream jos, Feature feature, Map<URI, Integer> locationMap) throws URISyntaxException {
for (BundleInfo bundleInfo : feature.getBundles()) {
URI location = new URI(bundleInfo.getLocation());
copyResourceToJar(jos, location, locationMap);
}
for (ConfigFileInfo configFileInfo : feature.getConfigurationFiles()) {
URI location = new URI(configFileInfo.getLocation());
copyResourceToJar(jos, location, locationMap);
}
}
use of org.apache.karaf.features.ConfigFileInfo in project karaf by apache.
the class JmxFeature method getConfigFileList.
static TabularData getConfigFileList(List<ConfigFileInfo> configFiles) throws OpenDataException {
TabularDataSupport table = new TabularDataSupport(FEATURE_CONFIG_FILES_TABLE);
for (ConfigFileInfo configFile : configFiles) {
String[] itemNames = FeaturesServiceMBean.FEATURE_CONFIG_FILES;
Object[] itemValues = { configFile.getFinalname() };
CompositeData config = new CompositeDataSupport(FEATURE_CONFIG_FILES, itemNames, itemValues);
table.put(config);
}
return table;
}
Aggregations