use of org.osgi.framework.wiring.BundleCapability in project karaf by apache.
the class PackageServiceImpl method getExports.
@Override
public List<String> getExports(long bundleId) {
Bundle bundle = bundleContext.getBundle(bundleId);
BundleRevision rev = bundle.adapt(BundleRevision.class);
List<BundleCapability> caps = rev.getDeclaredCapabilities(BundleRevision.PACKAGE_NAMESPACE);
List<String> exports = new ArrayList<>();
for (BundleCapability cap : caps) {
Map<String, Object> attr = cap.getAttributes();
String packageName = (String) attr.get(BundleRevision.PACKAGE_NAMESPACE);
exports.add(packageName);
}
return exports;
}
use of org.osgi.framework.wiring.BundleCapability in project karaf by apache.
the class Exports method getDuplicatePackages.
private SortedMap<String, PackageVersion> getDuplicatePackages(Bundle[] bundles) {
SortedMap<String, PackageVersion> packageVersionMap = new TreeMap<>();
for (Bundle bundle : bundles) {
BundleRevision rev = bundle.adapt(BundleRevision.class);
if (rev != null) {
List<BundleCapability> caps = rev.getDeclaredCapabilities(BundleRevision.PACKAGE_NAMESPACE);
for (BundleCapability cap : caps) {
Map<String, Object> attr = cap.getAttributes();
String packageName = (String) attr.get(BundleRevision.PACKAGE_NAMESPACE);
Version version = (Version) attr.get("version");
String key = packageName + ":" + version.toString();
PackageVersion pVer = packageVersionMap.computeIfAbsent(key, k -> new PackageVersion(packageName, version));
pVer.addBundle(bundle);
}
}
}
return packageVersionMap;
}
Aggregations