Tonny Madsen
Tonny Madsen

Reputation: 12718

What is the alternative to PackageAdmin.getFragments

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)?

Upvotes: 1

Views: 528

Answers (1)

Neil Bartlett
Neil Bartlett

Reputation: 23958

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();
}

Upvotes: 4

Related Questions