I have been working with OSGi for a while now, but I still don’t understand something about private packages.
- An exported package is a package with is visible to other bundles
- An imported package is a package which is imported by a bundle exporting the package.
- A private package is a package which is not visible to other bundles (I don’t get this)
Aren’t all bundle packages which are not exported invisible to all other packages? If so, what’s the difference to private packages and packages which are not exported?
I’ve read OSGi in Action and “OSGi and Apache Felix 3.0 – Beginners Guide”, but i was not able to find the difference.
Yes, all packages not defined in the manifest.mf entry
Export-Packageare private packages. You don’t need to specify them seperately, it’s just another term for the ease of communication.If you have your manifest generated as for example by the maven-bundle-plugin, this term get’s a little more relevant, because the maven bundle plugin will per default export all packages, except for example a package called
internal(or subpackages of that). This is somehow the inverse approach since you specify the private packages and have the exported package calculated. See the maven bundle plugin for details.