in src/main/java/org/apache/sling/settings/impl/SlingPropertiesPrinter.java [46:82]
public static void init(BundleContext bundleContext) throws IOException {
// if the properties are available, we register the sling properties plugin
Properties props;
final String propUrl = bundleContext.getProperty("sling.properties.url");
if ( propUrl != null ) {
// try to read properties
try (final InputStream is = new URL(propUrl).openStream()) {
final Properties tmp = new Properties();
tmp.load(is);
// update props
for(final Object key : tmp.keySet()) {
final Object value = bundleContext.getProperty(key.toString());
if ( value != null ) {
tmp.put(key, value);
}
}
props = tmp;
} catch (IOException ioe) {
LOGGER.error("Unable to read sling properties from '{}'", propUrl, ioe);
return;
}
} else {
LOGGER.debug("No bundle context property 'sling.properties.url' provided, not starting 'slingprops' webconsole plugin!");
return;
}
final SlingPropertiesPrinter propertiesPrinter = new SlingPropertiesPrinter(props);
final Dictionary<String, String> serviceProps = new Hashtable<>();
serviceProps.put("felix.webconsole.label", "slingprops");
serviceProps.put("felix.webconsole.title", "Sling Properties");
serviceProps.put("felix.webconsole.configprinter.modes", "always");
// no need to keep serviceregistration return value as deregistration only happens automatically once bundle stops
bundleContext.registerService(SlingPropertiesPrinter.class.getName(),
propertiesPrinter,
serviceProps);
}