Package dependencies and exports
Before going any further, it is very important to understand what OSGi package dependencies are, how they work and how to use them properly.
The OSGi framework will only let you access a Java package located in another OSGi bundle if:
- It is exported by an OSGi bundle
- It is imported by your own bundle
OSGi imports and exports must be declared in the
META-INF/MANIFEST.MF file. If an import or export is missing, or if versions of packages don’t match, no access to the package will be allowed by the bundle’s class loader. Management of the package imports and exports is the main learning curve involved in learning to use OSGi. Fortunately, Digital Experience Manager offers tooling such as the Jahia Maven Plugin that helps generate dependencies for common module projects. There are also other OSGi plugins available on the Internet but usually the Felix Maven Bundle Plugin and the Jahia Maven plugin should be sufficient for most projects.