6

I have two bundles: bundle A and bundle B which is configured as a fragment of bundle A using: Fragment-Host:

Whenever I install bundle B it fails to start (INSTALLED) and therefore to attach itseld to bundle A.

At this point when I check bundle A's status I see that it still doesn't recognize bundle B as its fragment.

If I do refresh bundle A it solves the problem - bundle B switches to RESOLVED and is able to attach itself to bundle A, bundle A recognizes bundle B as its fragment and everything is working as expected.

My question is how this refresh can be avoided, i.e. as soon as bundle B is installed it should attach itself to its host which is already ACTIVE.

Thank you.

Joly
  • 3,218
  • 14
  • 44
  • 70

1 Answers1

8

You cannot do that without a refresh, and it's in the OSGI specs too - to properly attach a fragment bundle, a transition from INSTALLED to RESOLVED of the host bundle is necessary. See section 3.14 of the 4.3 OSGi Core Specification.

Tassos Bassoukos
  • 16,017
  • 2
  • 36
  • 40
  • I thought so :( the thing is that even a container restart doesn't seem to resolve it only a refresh on the specific bundle host. Is that should be the case? – Joly Sep 02 '11 at 12:12
  • AFAIK yes, because the wiring between resolved packages/bundles is persisted. You will need to do this by hand, but you can do it programatically. – Tassos Bassoukos Sep 02 '11 at 12:39
  • Not example code, but for OSGi 4.3 and later frameworks look at the `FrameworkWiring` and `BundleWiring` interfaces, and section 7.6 of the 4.3 OSGi Specification. For pre-4.3 frameworks look into the `PackageAdmin` service. – Tassos Bassoukos Sep 02 '11 at 14:02
  • Thanks. Getting the host bundle through PackageAdmin and updating it seem to have solved it – Joly Sep 09 '11 at 12:57