felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard S. Hall" <he...@ungoverned.org>
Subject Re: Should a bundle import it's own packages?
Date Fri, 23 Feb 2007 03:06:39 GMT
Carlos Sanchez wrote:
> Seems that that's how the flix bundle plugin works, importing all
> packages that it exports. Is this right?

In OSGi R3 this was always the case, since Export-Package implied 
Import-Package. It was a good idea then and is generally a good idea now.

The whole point is substitutability of providers.

If you import what you export, then the framework is free to choose a 
different provider of those packages for your bundle, which means that 
your exports may go unused. However, this is a good thing, because the 
framework tries to minimize the number of active versions of a given 
package. This is a good thing because more active versions means 
divisions in the service registry and less interoperability of bundles.

If your bundle only exports its packages, then it is forcing the 
framework to use its own version, which can result in more active 
version of the given package.

In general, the main time you want to export only, is if your bundle is 
purely a library bundle, then its packages will only be used if they are 
needed or if you have tightly coupled bundles sharing implementation 
packages. However, if your bundle will be started and especially if the 
exported packages define service interfaces or are referenced from 
service interfaces, then you will want to export and import them.

-> richard

View raw message