Tuesday, February 19, 2013

Use of 'DynamicImport-Package: *' in OSGi

In OSGi, 'DynamicImport-Package' attribute is used in the MANIFEST.MF file to specify the patterns of packages that are not found in the normal bundle contents or Import-Package field. If the package is not available in the initial resolution process, it will not fail, but will be attempted to resolve every time a class from the package is required.

 'DynamicImport-Package: *' is a trick used by bundles to allow importing client packages which are not known during bundle build time, in addition to its own dependencies, to prevent ClassNotFoundException issues. [i.e. If there are classes which have Class.forName (or other dynamic look up)] This turns OSGi Framework into a very expensive class path for the packages involved and breaks the concept of versions in OSGi. Use of this attribute is said to be a sign of a non-modular design and it might be a good time to revisit the architecture.

To learn more:

1 comment: