Quantcast

What is the natural start order for dependent bundle?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

What is the natural start order for dependent bundle?

Xtra Coder
Hi,

I have a problem on 2.2.8 version of Karaf (and most probably on the earlier versions too).

I'm going to use Karaf to host the system with dynamically deployed bundles. Bundles are deployed by users and i cannot know beforehand which are they.

I expect order of the BundleActivator.start() to exactly correspond to dependencies between bundles (actually - dependencies of import/export packages) and planning to expect that it will be safe to assume that bundle0 will be completely initialized before bundle1 is going to be started. But it is not so - it seems that BundleActivator.start() is invoked in a "random" order and disregards package dependencies between bundles.

Sample use-case, I have 3 libs

    test-lib0 - defines testlib0.ITestRoot, exports testlib0 package
    test-lib1 - defines testlib1.TestRoot implements ITestRoot,  exports testlib1 package
    test-lib2 - uses both libs, ITestRoot and TestRoot

When Karaf is started, i see following sample output in console

    karaf@root> TestLib1Activator.start()
    TestLib2Activator.start()
            ITestRoot: interface com.testorg.testlib0.ITestRoot - 16634462
            TestRoot:  class com.testorg.testlib1.TestRoot - 21576551
    TestLib0Activator.start()

but i expect it should be always in this order

    TestLib0Activator.start()
    TestLib1Activator.start()
    TestLib2Activator.start()
            ITestRoot: interface com.testorg.testlib0.ITestRoot - 16634462
            TestRoot:  class com.testorg.testlib1.TestRoot - 21576551

I'm attaching sample project for tests. Test case: after "mvn install" just move jars from ./deploy folder to the same folder of Karaf, trace messages should appear in console.
(Note: it may work correctly from the first attempt, try one more time then :))

KarafTest.zip

PS: i've looked through these messages and did not find useful information on my topic
http://karaf.922171.n3.nabble.com/How-do-I-ensure-a-bundle-to-fully-initialized-before-another-bundle-starts-td3185618.html
http://stackoverflow.com/questions/7462259/how-is-the-osgi-bundle-start-level-defined
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What is the natural start order for dependent bundle?

Xtra Coder
Loading...