in src/main/java/org/apache/sling/feature/resolver/FrameworkResolver.java [82:120]
public FrameworkResolver(ArtifactManager am, Map<String, String> frameworkProperties) {
artifactManager = am;
Resolver r = null;
// Launch an OSGi framework and obtain its resolver
try {
FrameworkFactory fwf = ServiceLoader.load(FrameworkFactory.class).iterator().next();
framework = fwf.newFramework(frameworkProperties);
framework.init();
framework.start();
BundleContext ctx = framework.getBundleContext();
// Create a resource representing the framework
Map<String, List<Capability>> capabilities = new HashMap<>();
BundleRevision br = framework.adapt(BundleRevision.class);
capabilities.put(PackageNamespace.PACKAGE_NAMESPACE, br.getCapabilities(PackageNamespace.PACKAGE_NAMESPACE));
capabilities.put(BundleNamespace.BUNDLE_NAMESPACE, br.getCapabilities(BundleNamespace.BUNDLE_NAMESPACE));
capabilities.put(HostNamespace.HOST_NAMESPACE, br.getCapabilities(HostNamespace.HOST_NAMESPACE));
capabilities.put(IdentityNamespace.IDENTITY_NAMESPACE, br.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE));
frameworkResource = new BundleResourceImpl(framework.getSymbolicName(), framework.getVersion(), null, null,
capabilities, Collections.emptyMap());
int i=0;
while (i < 20) {
ServiceReference<Resolver> ref = ctx.getServiceReference(Resolver.class);
if (ref != null) {
r = ctx.getService(ref);
break;
}
// The service isn't there yet, let's wait a little and try again
Thread.sleep(500);
i++;
}
} catch (BundleException | InterruptedException e) {
throw new RuntimeException(e);
}
resolver = r;
}