public boolean allowsUpdate(DeploymentMetadata newMetadata, DeploymentMetadata oldMetadata) {
return true;
}
public void update(UpdateInfo info) throws UpdateException {
BundleFramework fwk = info.getAppFramework();
Bundle old = null;
for (Bundle b : fwk.getBundles()) {
if (b.getSymbolicName().equals("org.apache.aries.isolated.sample")) {
old = b;
break;
}
}
if (old == null) throw new RuntimeException("Could not find old bundle");
try {
info.unregister(old);
fwk.uninstall(old);
// only contains one element at most
Map<DeploymentContent, BundleSuggestion> suggestions =
info.suggestBundle(info.getNewMetadata().getApplicationDeploymentContents());
BundleSuggestion toInstall = suggestions.values().iterator().next();
Bundle newBundle = fwk.install(toInstall, info.getApplication());
info.register(newBundle);
if (info.startBundles()) fwk.start(newBundle);
} catch (Exception e) {
throw new RuntimeException(e);
}
}