[orbit-dev] FW: Support for OSGi
FYI - Why Apache Commons wants to keep using Import-Package
instead of Require-Bundle. I found the Spring DM / RCP /
Commons Logging Story very interesting.
I'll happily forward any comments to the Apache Mailing
Lists, since I find these different views on the subject
Martin Oberhuber, Senior Member of Technical Staff, Wind River
Target Management Project Lead, DSDP PMC Member
From: mcculls@xxxxxxxxx [mailto:mcculls@xxxxxxxxx] On Behalf Of Stuart
Sent: Freitag, 01. Februar 2008 17:56
Cc: Commons Developers List; Orbit Developer discussion
Subject: Re: Support for OSGi
> > http://dev.eclipse.org/mhonarc/lists/orbit-dev/msg00627.html
> > 1.) Looks like we Eclipse folk will need to continue writing
> > our own OSGi Manifests for some time since the
> > "Require-Bundle" vs. "Import-Package" patterns do not
> > mix too well.
True - of course, if you have several bundles exporting the same
but not importing them, then while this means Require-Bundle will be
predictable, it also means that you're more likely to see class cast
when you mix 'traditional' OSGi bundles with Eclipse plug-ins.
BTW, here's an example why Require-Bundle is so inflexible, from
Spring-DM uses the commons-logging API, but not the implementation
because it doesn't work well with OSGi classloading (see the
FAQ for more detail). People usually use Pax-Logging or other
which is possible because Spring-DM gets the API using
Recently a developer using Spring-DM and Eclipse RCP reported a
problem (he saw the usual exception when using the commons-logging
implementation) so we suggested he switched to another adapter.
Unfortunately he was also using the commons-discovery bundle (I think
from Orbit?) which has a Require-Bundle for commons-logging. This
dependency meant he couldn't substitute another logging bundle, while
he could have done if Import-Package was used.
In the end he re-bundled commons-discovery to use Import-Package
which fixed the problem, and he now has Spring-DM working with RCP.
Given that commons bundles will be used by the wider community then IMHO
they should use the Import-Package approach - hopefully plug-in
will start using it over Require-Bundle (at least for commons packages).
It would have been good to meet everyone's needs but from the link you
> posted and what Peter and Stuart have said in this thread then that
> doesn't seem possible and from my limited perspective it seems clear
> that we (in Commons) should follow whats considerd good OSGi practice
> rather than those of eclipse.
> > 2.) Whenever somebody converts an auto-generated OSGi Manifest
> > into a manually maintained one, it's worth thinking about
> > a) What packages are really API and thus worth being
> > exported, versus what packages are considered internal
> > hidden implementation;
Actually with Bnd, you tell it which packages to export and which to
private - it's just that most commons projects will start by exporting
packages, then over time mark some as private. Some commons jars
may also need Bundle-Activators to manage life-cycle issues, such as
background threads, etc. under OSGi.
You can read more about Bnd here: http://aqute.biz/Code/Bnd
> b) What packages are expected to be potentially split
> > across multiple bundles, or would always reside inside
> > the same bundle.
Again, while Bnd allows split-packages (with a warning) they are usually
not recommended from a 'traditional' OSGi perspective as they quickly
turn into a management nightmare.
FYI, SLF4J used to use split packages, but they refactored their jars to
avoid them, and it solved a lot of issues.