in src/main/java/org/apache/sling/feature/scanner/impl/fwk/FrameworkPropertiesGatherer.java [42:77]
public static void main(String [] args) throws Exception {
if (args.length != 2) {
System.err.print("usage: FrameworkPropertiesGatherer <in props filename> <out props filename>");
System.exit(1);
}
Properties inProps = new Properties();
try (Reader reader = new FileReader(args[0])) {
inProps.load(reader);
}
ServiceLoader<FrameworkFactory> ldr = ServiceLoader.load(FrameworkFactory.class);
FrameworkFactory ff = ldr.iterator().next();
@SuppressWarnings({ "unchecked", "rawtypes" })
Framework fwk = ff.newFramework((Map) inProps);
fwk.init();
fwk.start();
// The headers will contain the computed export packages and framework capabilities.
Dictionary<String, String> headers = fwk.getHeaders();
Properties outProps = new Properties();
outProps.put(Constants.FRAMEWORK_SYSTEMPACKAGES, headers.get(Constants.EXPORT_PACKAGE));
outProps.put(Constants.FRAMEWORK_SYSTEMCAPABILITIES, headers.get(Constants.PROVIDE_CAPABILITY));
fwk.stop();
try (Writer writer = new FileWriter(args[1])) {
outProps.store(writer, "Framework exports and capabilities");
}
fwk.waitForStop(1000);
System.exit(0); // To be sure
}