public Integer call()

in src/main/java/org/apache/sling/feature/launcher/impl/launchers/FrameworkRunner.java [73:125]


    public Integer call() throws Exception {
        // get the framework factory
        final FrameworkFactory factory = this.getFrameworkFactory();

        logger.info("Using framework factory {}", factory.getClass());
        // create the framework
        final Framework framework = factory.newFramework(frameworkProperties);
        // initialize the framework
        framework.init();

        long graceTime = Long.parseLong(frameworkProperties.getOrDefault(SHUTDOWN_GRACE_TIME, "60"));
        Runtime.getRuntime().addShutdownHook(new Thread() {
            @Override
            public void run() {
                try {
                    framework.stop();
                    FrameworkEvent waitForStop = framework.waitForStop(graceTime * 1000);
                    if (waitForStop.getType() != FrameworkEvent.STOPPED) {
                        logger.warn("Framework stopped with: " + waitForStop.getType(),
                                waitForStop.getThrowable());
                    } else {
                        logger.info("Framework stopped");
                    }
                } catch (BundleException | InterruptedException e) {
                    logger.warn("Exception stopping the framework in shutdown hook", e);
                }
            }
        });

        this.setupFramework(framework, bundlesMap);

        long time = System.currentTimeMillis();
        long startTimeout = Long.parseLong(frameworkProperties.getOrDefault(START_TIMEOUT, String.valueOf(10 * 60)));

        // finally start
        if (!this.startFramework(framework, startTimeout, TimeUnit.SECONDS)) {
            throw new TimeoutException("Waited for more than " + startTimeout + " seconds to startup framework.");
        }
        this.finishStartup(framework);
        logger.info("Framework started");

        logger.debug("Startup took: " + (System.currentTimeMillis() - time));

        while ((type = framework.waitForStop(Long.MAX_VALUE).getType()) == FrameworkEvent.STOPPED_UPDATE) {
            logger.info("Framework restart due to update");
            time = System.currentTimeMillis();
            if (!this.startFramework(framework, startTimeout, TimeUnit.SECONDS)) {
                throw new TimeoutException("Waited for more than " + startTimeout + " seconds to startup framework.");
            }
            logger.debug("Restart took: " + (System.currentTimeMillis() - time));
        }
        return type;
    }