protected Sling startSling()

in src/main/java/org/apache/sling/maven/projectsupport/RunMojo.java [67:97]


    protected Sling startSling(LaunchpadContentProvider resourceProvider, final Map<String, String> props, Logger logger)
            throws BundleException {
        if (!registeredHook) {
            Runtime.getRuntime().addShutdownHook(shutdown);
            registeredHook = true;
        }
        
        // creating the instance launches the framework and we are done here
        Sling mySling = new Sling(this, logger, resourceProvider, props) {

            // overwrite the loadPropertiesOverride method to inject the
            // mojo arguments unconditionally. These will not be persisted
            // in any properties file, though
            protected void loadPropertiesOverride(
                    Map<String, String> properties) {
                if (props != null) {
                    properties.putAll(props);
                }
            }
        };

        // TODO this seems hacky!
        try {
            while (mySling != null) {
                Thread.sleep(100);
            }
        } catch (InterruptedException e) {
        }

        return mySling;
    }