Search code examples
javaeclipseosgibundleequinox

osgi bundle lifecycle question


I try to learn how osgi works. I've written my first hello-world bundle which gives some console output when the start-method of the bundle activator class is executed. Now, I've read about the lazy starting mechanism and I put this flag to my bundle manifest. then, I started the equinox console, installed my bundle and started it. but now I would have expected my bundle to be marked as 'starting'. but instead it already calls it's start method and is marked as active. did I understand anything wrong with the lazy starting mechanism???


Solution

  • The lazy-start flag is used when you have other bundles that depend on your bundle and classes in your bundle.

    Say you have two bundles A and B, where

    • A exports the class C
    • B depends on A
    • B contains a class D that refers C

    What happens when the bundle B is activated?

    Without the lazy-load flag, the A bundle is loaded and activated first.

    With the lazy-load flag, the A bundle is not loaded or activated until the class D needs to refer to the class C.

    That can make a very big difference in the activation profile, as the load and activation of bundles are postponed to happen as late as possible with the lazy-load flag so the initial response from the bundle is very fast...

    On the contrary, this flag also makes it a hole lot more difficult to reason about the execution time for methods in B as this can be intercepted with load and activation of bundles at any time....