} finally {
IOUtils.close(fi);
}
reference = context.getServiceReference(PackageAdmin.class.getName());
PackageAdmin packageAdmin = (PackageAdmin) context.getService(reference);
Bundle[] bundles = new Bundle [] { targetBundle };
// resolve the bundle
if (!packageAdmin.resolveBundles(bundles)) {
StringBuilder builder = new StringBuilder();
builder.append("Updated ").append(bundleName).append(" bundle cannot be resolved.");
// check for resolver errors
ResolverErrorAnalyzer errorAnalyzer = new ResolverErrorAnalyzer(context);
String resolverErrors = errorAnalyzer.getErrorsAsString(Arrays.asList(bundles));
if (resolverErrors != null) {
builder.append(" ").append(resolverErrors);
}
throw new BundleException(builder.toString());
}
Set<Bundle> dependents = new HashSet<Bundle>();
collectDependentBundles(packageAdmin, dependents, targetBundle);
if (!dependents.isEmpty()) {
String bundleListString = bundleCollectionToString(dependents);
LOG.info("Update of {} bundle will cause the following bundles to be refreshed: {}", bundleName, bundleListString);
}
// install listener for package refresh
refreshListener = new RefreshListener();
context.addFrameworkListener(refreshListener);
// refresh the bundle - this happens asynchronously
packageAdmin.refreshPackages(bundles);
// update application archive
try {
updateArchive(targetBundle, bundleFile);
} catch (Exception e) {