in src/main/java/org/apache/sling/maven/jspc/FeatureSupport.java [73:125]
public static FeatureSupport createFeatureSupport(Feature feature, ArtifactProvider provider, ClassLoader loader, boolean failOnUnresolvedBundles,
Function<Map<String, String>, Map<String, String>> frameworkPropertiesHandler) throws BundleException {
FrameworkFactory factory = ServiceLoader.load(FrameworkFactory.class, loader).iterator().next();
Map<String, String> properties = new HashMap<>(feature.getFrameworkProperties());
properties = frameworkPropertiesHandler.apply(properties);
Map<String, String> frameworkProperties = new HashMap<>();
properties.forEach((key, value) -> {
frameworkProperties.put(key, value.replace("{dollar}", "$"));
});
Framework framework = factory.newFramework(frameworkProperties);
framework.init();
try {
List<Bundle> bundles = install(framework, feature, provider);
framework.start();
for (Bundle bundle : bundles) {
if (bundle.getState() != Bundle.RESOLVED) {
boolean resolved = framework.adapt(FrameworkWiring.class).resolveBundles(Arrays.asList(bundle));
if (!resolved && failOnUnresolvedBundles) {
throw new BundleException("Unable to resolve bundle: " + bundle.getLocation());
}
}
}
ServiceTracker<PackageAdmin, PackageAdmin> tracker = new ServiceTracker<>(framework.getBundleContext(), PackageAdmin.class, null);
tracker.open();
PackageAdmin admin = tracker.waitForService(1000);
DynamicClassLoaderManagerImpl manager = new DynamicClassLoaderManagerImpl(framework.getBundleContext(), admin, loader,
new DynamicClassLoaderManagerFactory(framework.getBundleContext(), admin));
SlingTldLocationsCache tldLocationsCache = new SlingTldLocationsCache(framework.getBundleContext());
FeatureSupport featureSupport = new FeatureSupport(framework, manager.getDynamicClassLoader(), tldLocationsCache, feature);
return featureSupport;
} catch (Throwable t) {
try {
framework.stop();
framework.waitForStop(10000);
} finally {
throw new RuntimeException(t);
}
}
}