Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [orbit-dev] Apache Commons going OSGi

This comes from a more traditional OSGi mind set where Require-Bundle is the exception and is considered a bad practice. Exporting and importing the same package allows for the greatest amount of substitutability and allows a greater number of bundles to all use the same supplier of a package. I will give a small example to illustrate

Bundle-SymbolicName: A
Export-Package:; version=1.0
Import-Package:; version=1.0

Bundle-SymbolicName: B
Export-Package:; version=1.0
Import-Package:; version=1.0

Bundle-SymbolicName: C
Export-Package:; version=1.0
Import-Package:; version=1.0

Bundle-SymbolicName: D
Import-Package:; version=1.0

Bundle-SymbolicName: E
Require-Bundle: C

In this example bundles A, B, and C all and import "". In OSGi when a bundle both exports and imports the same package then it gets choosen as either an importer or an exporter, it cannot be both at the same time. What this allows the Framework to do is pick a single exporter of "" and cause the rest of the bundles to become importers of In this case imagine the Framework picks bundle A to become the exporter of "" and bundles B, C and D become importers of "" and get wired to the "" exported by bundle A.

This practice has an unfortunate side-effect on clients which use Require-Bundle. In this case bundle E required bundle C. In some configurations bundle C may be chosen as the exporter of "" and in other configurations it may be chosen as an importer of "". This makes bundle E's access to the package from Bundle C unpredictable.

In the Eclipse community bundles are commonly thought of as library bundles where the Bundle-SymbolicName is considered API and the packages available to Require-Bundle clients is predictable and consistently evolved from one version of the bundle to the next. Also in Eclipse community Require-Bundle is the norm since it most closely models the eclipse world as it was before the use of OSGi. We need to be aware of this situation when producing the library bundles in orbit. In most cases this means we cannot export and import the same package in the orbit bundles. If we did want to do that then we would need to have a very concerted and coordinated effort to change the mind set of the whole Eclipse community to stop using Require-Bundle. That is not something I can see happening in the short or even mid-term.


Inactive hide details for "Oberhuber, Martin" ---01/31/2008 07:57:52 AM---Dear bundle experts,"Oberhuber, Martin" ---01/31/2008 07:57:52 AM---Dear bundle experts,


"Oberhuber, Martin" <Martin.Oberhuber@xxxxxxxxxxxxx>


"Orbit Developer discussion" <orbit-dev@xxxxxxxxxxx>


01/31/2008 07:57 AM


[orbit-dev] Apache Commons going OSGi

Dear bundle experts,

it has come to my attention that Apache Commons
is partially going OSGi:

what struck me on that page is that they claim
"Everything that's exported should also be
imported". That seems wrong to me, since it
does not make sense to import-package something
that's defined in the same bundle.


Martin Oberhuber, Senior Member of Technical Staff, Wind River
Target Management Project Lead, DSDP PMC Member

orbit-dev mailing list

GIF image

GIF image

Back to the top