简体   繁体   中英

Resolve OSGi bundle from code

I have to programmatically ensure a specific start order of several OSGi bundles because the activation procedure has some dependencies to other bundles. I manage the bundle's life cycle from Java code where I try to determine the bundle's wiring to calculate the correct start order. All bundles are installed correctly.

Because the bundle wiring seams to be initialised in the resolved state, I am looking for a way to programmatically resolve a bundle. I only found bundle.start() which resolves but also starts the bundle. Is there a way to only resolve without start? If I use the OSGi shell manually I can achieve this by resolve <bundle-id> .

There is no way you can do this in a reliable and robust way. OSGi has no start ordering. period. out. get over it.

The reason is simple, a bundle could be stopped and that throws of any ingenious ordering you invented at startup.

The only ordering that works is service dependencies. Each component should specify what services it depends on and not start before the services it needs are registered. That is the ONLY reliably way to get ordering.

This is of course trivial to do when you can use DS.

You can resolve a set of bundles with FrameworkWiring.resolveBundles . But resolving a bundle is just a necessary precursor to starting a bundle but has nothing to do with ordering. You can resolve all the bundles at once and then start the bundles in a random order.

As Peter says, if you need to start the bundles in some specific order, something is wrong with your system. How will it handle updating a bundle?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM