views:

42

answers:

1

1) Bundle A reexports package com.X, which it gets from bundle C


2) Bundle B exports package com.X


3) Now bunlde D has dependency on both A and B.


From where will the bundle D get the package com.X from?

A: 

The first question is why you have 2 bundles defining the same package - this is called split packages and isn't recommended because you can have problems with shadowing.

With Import-Package the runtime will pick either bundle A or B to resolve the package dependency and you can't control this directly (you can do various tricks like the Eclipse guys do by setting mandatory properties on the exports).

With Require-Bundle you'll end up with a merged com.X package, so you'll see the superset of types, but I'm not sure what happens if you have overlapping types.

The simplest thing is to avoid split packages in the first place.

hbunny
thanks steven, your answer was helpful. You mentioned : "various tricks like the Eclipse guys do by setting mandatory properties on the exports".... Can you tell what are these techniques. Thanks.
Suraj Chandran
When a bundle exports a package it can optionally specify additional key/value pairs (they can be anything you want). These additional key/value pairs can be marked as mandatory, so other bundles can only do the Import-Package if they also specify the same key/value pairs. Some Eclipse bundles use this technique because they have split packages, but I believe this is more a legacy issue and you should avoid it if possible.
hbunny