in src/main/java/org/apache/sling/feature/launcher/impl/launchers/FrameworkLauncher.java [64:135]
public int run(final LauncherRunContext context, final ClassLoader cl) throws Exception {
final VariableSubstitutor vs = new VariableSubstitutor(context);
Map<String, String> properties = new HashMap<>();
context.getFrameworkProperties().forEach((key, value) -> {
properties.put(key, vs.replace(value).replace("{dollar}", "$"));
});
if (context.getLogger().isDebugEnabled()) {
context.getLogger().debug("Bundles:");
for(final Integer key : context.getBundleMap().keySet()) {
context.getLogger().debug("-- Start Level {}", key);
for(final URL f : context.getBundleMap().get(key)) {
context.getLogger().debug(" - {}", f);
}
}
context.getLogger().debug("Settings: ");
for(final Map.Entry<String, String> entry : properties.entrySet()) {
context.getLogger().debug("- {}={}", entry.getKey(), entry.getValue());
}
context.getLogger().debug("Configurations: ");
for(final Object[] entry : context.getConfigurations()) {
if ( entry[1] != null ) {
context.getLogger().debug("- Factory {} - {}", entry[1], entry[0]);
} else {
context.getLogger().debug("- {}", entry[0]);
}
}
context.getLogger().debug("");
}
final Class<?> runnerClass = cl.loadClass(getFrameworkRunnerClass());
final Constructor<?> constructor = runnerClass.getDeclaredConstructor(Map.class, Map.class, List.class,
List.class);
constructor.setAccessible(true);
@SuppressWarnings("unchecked")
Callable<Integer> restart = (Callable<Integer>) constructor.newInstance(properties, context.getBundleMap(),
context.getConfigurations(), context.getInstallableArtifacts());
setOptionalSupplier(restart, "setFeatureSupplier", new Supplier<Object>() {
@Override
public Object get() {
try ( final StringWriter writer = new StringWriter()) {
FeatureJSONWriter.write(writer, feature);
writer.flush();
return writer.toString();
} catch ( final IOException ignore) {
// ignore
}
return null;
}
});
setOptionalBiConsumer(restart, "setBundleReporter", new BiConsumer<URL, Map<String, String>>() {
@Override
public void accept(final URL url, final Map<String, String> values) {
final String urlString = url.toString();
for(final Artifact a : feature.getBundles()) {
if ( urlString.equals(a.getMetadata().get(URL.class.getName()))) {
for(final Map.Entry<String, String> entry : values.entrySet()) {
a.getMetadata().put(entry.getKey(), entry.getValue());
}
break;
}
}
}
});
return restart.call();
// nothing else to do, constructor starts everything
}