Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] [OSGi] practices with the bundle context

What are the regular practice with the bundleContext?
    Do you store it?

No, it is a transient object, so storing it will do no good.

    Do you make it accessible to other classes in the bundle?

Yes, usually you do. It is important though not to let a BundleContext leak out to other bundles. The BundleContext is a bundle's interface to the framework, so a bundle can masquerade as another bundle if it has that bundle's BundleContext.

Do you surface some of its API in the activator and store the activator somewhere?

I wouldn't surface the API in the activator, but certainly you may surface some of the functionality in other objects. Often though you just end up passing around the BundleContext.

Basically it offers a lot of functions that are interesting to install bundles, and get information about the platform. So how am I supposed to proceed for other classes of my bundle to use those facility?

Except for instances where the BundleContext may leak to other bundles, I wouldn't feel bad about passing around the BundleContext.

ben



Back to the top