in src/main/java/org/apache/sling/feature/scanner/Scanner.java [244:303]
private void populateCache(Feature feature) throws IOException {
AnalyserMetaDataExtension extension = AnalyserMetaDataExtension.getAnalyserMetaDataExtension(feature);
if (extension != null) {
for (Artifact bundle : feature.getBundles()) {
ArtifactId id = bundle.getId();
final String key = id.toMvnId()
.concat(":")
.concat(String.valueOf(bundle.getStartOrder()))
.concat(":")
.concat(Stream.of(bundle.getFeatureOrigins())
.map(ArtifactId::toMvnId)
.collect(Collectors.joining(",")));
if (this.cache.get(key) == null) {
Map<String, String> headers = extension.getManifest(id);
if (headers != null) {
Manifest manifest = new Manifest();
headers.forEach(manifest.getMainAttributes()::putValue);
BundleDescriptor desc = new BundleDescriptorImpl(bundle, artifactProvider, manifest);
this.cache.put(key, desc);
}
}
}
SystemBundle systemBundle = extension.getSystemBundle();
if (systemBundle != null) {
URL artifactUrl = artifactProvider.provide(systemBundle.getArtifactId());
if (artifactUrl == null) {
throw new IOException("Unable to find file for " + systemBundle.getArtifactId());
}
BundleDescriptor desc = new SystemBundleDescriptor(systemBundle.getArtifactId(), artifactUrl);
String capabilities = systemBundle.getManifest().get(Constants.PROVIDE_CAPABILITY);
if (capabilities != null) {
try {
List<Capability> parsedCapabilities = ResourceBuilder.parseCapability(null, capabilities);
desc.getCapabilities().addAll(parsedCapabilities);
} catch (BundleException e) {
throw new IOException("Failed to parse capabilites for the system bundle", e);
}
}
String exports = systemBundle.getManifest().get(Constants.EXPORT_PACKAGE);
if (exports != null) {
Clause[] pcks = Parser.parseHeader(exports);
for (final Clause pck : pcks) {
String version = pck.getAttribute("version");
PackageInfo info = new PackageInfo(pck.getName(), version, false);
desc.getExportedPackages().add(info);
}
}
desc.lock();
String key = systemBundle.getScannerCacheKey();
this.cache.put(key, desc);
}
}
}