osgibundleosgi-fragment

Using the OSGi API, how do I find out if a given bundle is a fragment?


In the OSGi API, a call to BundleContext.getBundles() returns all bundles, whether they are fragments or not. For a given Bundle object, what is the best way to tell if this is a fragment or not?


Solution

  • Best way:

    (bundle.adapt(BundleRevision.class).getTypes() & BundleRevision.TYPE_FRAGMENT) != 0