On class visibility

Looking up the inventory service from the bookshelf service code gives it access to objects hosted in another bundle (namely, in the bookshelf-inventory-impl-mock bundle).

This is not of any great impact in this example, however, it is a good idea to keep in mind that those classes live in different bundles. The wiring made it so that the inventory implementation classes are visible from the bookshelf service context.

When working on more complex bundles that would need to make use of class or resource loaders, the bundle codebases and their class loaders are managed by the Felix framework. It's not always correct to assume that another object's class loader is the same as ours or that we're in the same class space. Remember to use the methods made available by the target bundle BundleContext for loading resources from that bundle.

Pop quiz

  1. When a bundle is started, it goes through which sequence of states?

    a. RESOLVED, INSTALLED, and then STARTED.

    b. DOWNLOADED, INSTALLED, and then STARTED.

    c. INSTALLED, RESOLVED, STARTING, and then ACTIVE.

  2. When are the BundleActivator methods called?

    a. When the bundle is starting.

    b. When the bundle is stopping.

    c. a and b.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.12.157