in src/main/java/org/apache/sling/launchpad/base/impl/BootstrapInstaller.java [425:516]
private boolean installBundle(final File bundleJar,
final int startLevel,
final Map<String, Bundle> currentBundles,
final List<Bundle> installed) {
// get the manifest for the bundle information
Manifest manifest = getManifest(bundleJar);
if (manifest == null) {
logger.log(Logger.LOG_ERROR, "Ignoring " + bundleJar
+ ": Cannot read manifest");
return false; // SHORT CIRCUIT
}
// ensure a symbolic name in the jar file
String symbolicName = getBundleSymbolicName(manifest);
if (symbolicName == null) {
logger.log(Logger.LOG_ERROR, "Ignoring " + bundleJar
+ ": Missing " + Constants.BUNDLE_SYMBOLICNAME
+ " in manifest");
return false; // SHORT CIRCUIT
}
// check for an installed Bundle with the symbolic name
Bundle installedBundle = currentBundles.get(symbolicName);
if (ignore(installedBundle, manifest)) {
logger.log(Logger.LOG_INFO, "Ignoring " + bundleJar
+ ": More recent version already installed");
return false; // SHORT CIRCUIT
}
// try to access the JAR file, ignore if not possible
InputStream ins;
try {
ins = new FileInputStream(bundleJar);
} catch (FileNotFoundException e) {
return false; // SHORT CIRCUIT
}
final boolean requireRestart;
if (installedBundle != null) {
// if the installed bundle is an extension fragment we have to
// restart the framework after completing the installation
// or upgrade of all new bundles
requireRestart = isSystemBundleFragment(installedBundle);
try {
installedBundle.update(ins);
logger.log(Logger.LOG_INFO, "Bundle "
+ installedBundle.getSymbolicName()
+ " updated from " + bundleJar);
// optionally set the start level
if (startLevel > 0) {
installedBundle.adapt(BundleStartLevel.class).setStartLevel(startLevel);
}
} catch (BundleException be) {
logger.log(Logger.LOG_ERROR, "Bundle update from "
+ bundleJar + " failed", be);
}
} else {
// restart is not required for any bundle installation at this
// stage
requireRestart = false;
// install the JAR file as a bundle
String path = bundleJar.getPath();
String location = SCHEME
+ path.substring(path.lastIndexOf('/') + 1);
try {
Bundle theBundle = bundleContext.installBundle(location, ins);
logger.log(Logger.LOG_INFO, "Bundle "
+ theBundle.getSymbolicName() + " installed from "
+ location);
// finally add the bundle to the list for later start
installed.add(theBundle);
// optionally set the start level
if (startLevel > 0) {
theBundle.adapt(BundleStartLevel.class).setStartLevel(startLevel);
}
} catch (BundleException be) {
logger.log(Logger.LOG_ERROR,
"Bundle installation from " + location + " failed", be);
}
}
return requireRestart;
}