javaosgiapache-karafosgi-fragment

How to specify multiple hosts in the manifest of an OSGI fragment bundle in apache karaf


According to the OSGI specification, a fragment bundle in OSGI can have multiple hosts. But in apache karaf it does not seem to work.

I have tried the following.

Fragment-Host: default_host;bundle-version=1.0.0,Second_host;bundle-version=1.0.0

Solution

  • You are right that a fragment can have multiple hosts according to the specification. But it seems to be limited to different versions of bundles with the same symbolic name:

    The grammar for Fragment-Host is defined as

    Fragment-Host       ::= bundle-description
    bundle-description  ::= symbolic-name ( ';' parameter )*
    

    and by using a version range, you technically define multiple host:

    bundle-version - The version range to select the host bundle. If a range is used, then the fragment can attach to multiple hosts.

    It doesn't seem to be possible to attach a fragment to host bundles with different names like in your example.