boolean install()

in src/main/java/org/apache/sling/launchpad/base/impl/BootstrapInstaller.java [163:250]


    boolean install() throws IOException {

        String launchpadHome = bundleContext.getProperty(SharedConstants.SLING_LAUNCHPAD);
        if (launchpadHome == null) {
            launchpadHome = bundleContext.getProperty(SharedConstants.SLING_HOME);
        }
        final File slingStartupDir = getSlingStartupDir(launchpadHome);

        // execute bootstrap commands, if needed
        final BootstrapCommandFile cmd = new BootstrapCommandFile(logger,
            new File(launchpadHome, BOOTSTRAP_CMD_FILENAME));
        boolean requireRestart = cmd.execute(bundleContext);

        boolean shouldInstall = false;

        // see if the loading of bundles from the package is forced
        final String fpblString = bundleContext.getProperty(SharedConstants.FORCE_PACKAGE_BUNDLE_LOADING);
        if (Boolean.valueOf(fpblString)) {
            shouldInstall = true;
        } else {
            shouldInstall = this.startupMode != StartupMode.RESTART;
        }

        if (shouldInstall) {
            // only run the war/jar copies when this war/jar is new/changed

            // see if the loading of bundles from the package is disabled
            String dpblString = bundleContext.getProperty(SharedConstants.DISABLE_PACKAGE_BUNDLE_LOADING);
            Boolean disablePackageBundleLoading = Boolean.valueOf(dpblString);

            if (disablePackageBundleLoading) {
                logger.log(Logger.LOG_INFO, "Package bundle loading is disabled so no bundles will be installed from the resources location in the sling jar/war");
            } else {
                // get the bundles out of the jar/war and copy them to the startup location
                Iterator<String> resources = resourceProvider.getChildren(PATH_BUNDLES);
                while (resources.hasNext()) {
                    String path = resources.next();
                    // only consider folders
                    if (path.endsWith("/")) {

                        // cut off trailing slash
                        path = path.substring(0, path.length() - 1);

                        // calculate the startlevel of bundles contained
                        int startLevel = getStartLevel(path);
                        if (startLevel != STARTLEVEL_NONE) {
                            copyBundles(slingStartupDir, path, startLevel);
                        }
                    }
                }

                // copy old-style core bundles
                copyBundles(slingStartupDir, PATH_CORE_BUNDLES, STARTLEVEL_CORE_BUNDLES);

                // copy old-style bundles
                copyBundles(slingStartupDir, PATH_BUNDLES, STARTLEVEL_BUNDLES);

                // done with copying at this point
            }

            // get the set of all existing (installed) bundles by symbolic name
            Bundle[] bundles = bundleContext.getBundles();
            Map<String, Bundle> bySymbolicName = new HashMap<String, Bundle>();
            for (int i = 0; i < bundles.length; i++) {
                bySymbolicName.put(bundles[i].getSymbolicName(), bundles[i]);
            }

            // holds the bundles we install during this processing
            List<Bundle> installed = new LinkedList<Bundle>();

            // get all bundles from the startup location and install them
            requireRestart |= installBundles(slingStartupDir, bySymbolicName, installed);

            // start all the newly installed bundles (existing bundles are not started if they are stopped)
            startBundles(installed);
        }

        // due to the upgrade of a framework extension bundle, the framework
        // has to be restarted. For this reason, set the target start level
        // to a negative value.
        if (requireRestart) {
            logger.log(
                Logger.LOG_INFO,
                "Framework extension(s) have been updated, restarting framework after startup has completed");
        }

        return requireRestart;
    }