Search code examples
osgiequinox

How to get a system bundle fragment version at runtime


I've created a system bundle fragment for a host bundle using this:

Fragment-Host: system.bundle;extension:=framework

I would like to know the version of the fragment inside the system bundle activator method. there is way to get that ?

If I use the context parameter of the activator method I can get the system bundle but couldn't find how to get its fragments...

thanks in advance.


Solution

  • Check OSGi Core Spec 5.0 (7.2.x chapter)

      BundleWiring wA = systemBundleContext.getBundle().adapt( BundleWiring.class );
      for ( BundleWire wire : wA.getProvidedWires(HOST_NAMESPACE)) {
        // fragment bundle version
        wire.getRequirerWiring().getResource().getVersion();
      }