private Map loadConfigProperties()

in src/main/java/org/apache/sling/launchpad/base/webapp/SlingServletDelegate.java [348:409]


    private Map<String, String> loadConfigProperties(String slingHome) {
        // The config properties file is either specified by a system
        // property or it is in the same directory as the Felix JAR file.
        // Try to load it from one of these places.
        Map<String, String> props = new HashMap<String, String>();

        final String servletVersion = getServletContext().getMajorVersion() + "." +
                                      getServletContext().getMinorVersion();
        // This property must start with a comma!
        props.put(
                 Sling.PROP_SYSTEM_PACKAGES,
                ",".concat(calculateServletPackages(servletVersion, getServletContext().getMajorVersion())));
        // extra capabilities
        final String servletCaps = "osgi.contract;osgi.contract=JavaServlet;version:Version=\" " + servletVersion + "\";" +
                        "uses:=\"javax.servlet,javax.servlet.http,javax.servlet.descriptor,javax.servlet.annotation\"";
        props.put(Sling.PROP_EXTRA_CAPS, servletCaps);

        // prevent system properties from being considered
        props.put(Sling.SLING_IGNORE_SYSTEM_PROPERTIES, "true");

        if (this.properties != null) {
            props.putAll(this.properties);
        } else {
            // copy context init parameters
            Enumeration<String> cpe = getServletContext().getInitParameterNames();
            while (cpe.hasMoreElements()) {
                String name = cpe.nextElement();
                props.put(name, getServletContext().getInitParameter(name));
            }

            // copy servlet init parameters
            Enumeration<String> pe = getInitParameterNames();
            while (pe.hasMoreElements()) {
                String name = pe.nextElement();
                props.put(name, getInitParameter(name));
            }
        }

        // ensure the Felix Logger loglevel matches the Sling log level
        checkLogSettings(props);

        // if the specified obr location is not a url and starts with a '/', we
        // assume that this location is inside the webapp and create the correct
        // full url
        final String repoLocation = props.get(OBR_REPOSITORY_URL);
        if (insideWebapp(repoLocation)) {
            final URL url = getUrl(repoLocation);
            // only if we get back a resource url, we update it
            if (url != null)
                props.put(OBR_REPOSITORY_URL, url.toExternalForm());
        }

        // set sling home
        props.put(SharedConstants.SLING_HOME, slingHome);

        // ensure sling.launchpad is set
        if (!props.containsKey(SharedConstants.SLING_LAUNCHPAD)) {
            props.put(SharedConstants.SLING_LAUNCHPAD, slingHome);
        }

        return props;
    }