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: foo.bar; version=1.0
Import-Package: foo.bar; version=1.0

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

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

Bundle-SymbolicName: D
Import-Package: foo.bar; version=1.0

Bundle-SymbolicName: E
Require-Bundle: C

In this example bundles A, B, and C all and import "foo.bar". 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 "foo.bar" and cause the rest of the bundles to become importers of foo.bar. In this case imagine the Framework picks bundle A to become the exporter of "foo.bar" and bundles B, C and D become importers of "foo.bar" and get wired to the "foo.bar" 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 "foo.bar" and in other configurations it may be chosen as an importer of "foo.bar". This makes bundle E's access to the foo.bar 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.

Tom



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,


From:

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

To:

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

Date:

01/31/2008 07:57 AM

Subject:

[orbit-dev] Apache Commons going OSGi




Dear bundle experts,

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

http://wiki.apache.org/commons/CommonsOsgi

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.

Thoughts?

Cheers,
--
Martin Oberhuber, Senior Member of Technical Staff, Wind River
Target Management Project Lead, DSDP PMC Member
http://www.eclipse.org/dsdp/tm

_______________________________________________
orbit-dev mailing list
orbit-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/orbit-dev

GIF image

GIF image


Back to the top