What is the alternative to PackageAdmin.getFragments

523 Views Asked by At

With OSGi 4.3, I understand PackageAdmin has been deprecated. How do you then find the fragments for a specific bundle - i.e. what is the alternative to PackageAdmin.getFragments(Bundle bundle)?

1

There are 1 best solutions below

2
On BEST ANSWER

Use the BundleWiring API to find the provided wires in the osgi.wiring.host namespace:

BundleWiring myWiring = myBundle.adapt(BundleWiring.class);
List<BundleWire> wires = myWiring.getProvidedWires(HostNamespace.HOST_NAMESPACE);
for (BundleWire wire : wires) {
    Bundle fragment = wire.getRequirerWiring().getBundle();
}