public void installFeature(String name) throws Exception {
installFeature(name, FeatureImpl.DEFAULT_VERSION);
}
public void installFeature(String name, String version) throws Exception {
Feature f = getFeature(name, version);
if (f == null) {
throw new Exception("No feature named '" + name
+ "' with version '" + version + "' available");
}
for (Feature dependency : f.getDependencies()) {
installFeature(dependency.getName(), dependency.getVersion());
}
for (String config : f.getConfigurations().keySet()) {
Dictionary<String,String> props = new Hashtable<String, String>(f.getConfigurations().get(config));
String[] pid = parsePid(config);
if (pid[1] != null) {
props.put(ALIAS_KEY, pid[1]);
}
Configuration cfg = getConfiguration(configAdmin, pid[0], pid[1]);
if (cfg.getBundleLocation() != null) {
cfg.setBundleLocation(null);
}
cfg.update(props);
}
Set<Long> bundles = new HashSet<Long>();
for (String bundleLocation : f.getBundles()) {
Bundle b = installBundleIfNeeded(bundleLocation);
bundles.add(b.getBundleId());
}
for (long id : bundles) {
bundleContext.getBundle(id).start();