Installing a fragment requires a refresh on the host, how can this be avoided?
Asked Answered
S

1

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.

Scuppernong answered 2/9, 2011 at 9:4 Comment(0)
R
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.

Rag answered 2/9, 2011 at 11:18 Comment(4)
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?Scuppernong
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.Rag
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.Rag
Thanks. Getting the host bundle through PackageAdmin and updating it seem to have solved itScuppernong

© 2022 - 2024 — McMap. All rights reserved.