Sure, that's probably more appropriate for the discussion concerning the
code, but I think the question remains for osgi-dev:

Why is it considered a good practice (as it's enforced by bnd) in OSGi to
only import the exported packages if they're used by private packages (as
opposed to contained packages) ?

Thanks
--G

PS: Here is the link for those interested in the bndtools-users' answers:
https://groups.google.com/forum/?fromgroups#!topic/bndtools-users/vp602qv0ndI


2012/7/10 BJ Hargrave <[email protected]>

> Perhaps you meant to send this to [email protected]?
>
> --
>
>  *BJ Hargrave*
> Senior Technical Staff Member, IBM
> OSGi Fellow and CTO of the *OSGi Alliance* <http://www.osgi.org/>*
> **[email protected]* <[email protected]>
>
> office: +1 386 848 1781
> mobile: +1 386 848 3788
>
>
>
>
>
>
> From:        "Guillaume Sauthier (OW2)" <[email protected]>
> To:        OSGi Developer Mail List <[email protected]>,
> Date:        2012/07/10 09:03
> Subject:        [osgi-dev] Exported packages are not auto-magically
> imported
> Sent by:        [email protected]
> ------------------------------
>
>
>
> Hi all
>
> Recently, I updated my maven-bundle-plugin from 2.1.0 to latest 2.3.7, and
> I observed a change in the list of imported packages.
>
> I have 2 different uses case:
> 1. Wrapping an existing library (say one of the commons-*) and thus
> exporting all of its packages
> 2. Creating a Bundle of our own with an API package and an implementation
> package, but with both packages exported (no services around here, so it's
> mostly like a library, but with an API)
>
> So the change was that the exported packages were usually automatically
> imported, and it's no more the case.
>
> After digging in Bnd, I found the following issue:
> *https://github.com/bndtools/bnd/issues/6*<https://github.com/bndtools/bnd/issues/6>
>
> ... that looks related to that part of bnd:
> *
> https://github.com/bndtools/bnd/blob/master/biz.aQute.bndlib/src/aQute/lib/osgi/Analyzer.java#L954
> *<https://github.com/bndtools/bnd/blob/master/biz.aQute.bndlib/src/aQute/lib/osgi/Analyzer.java#L954>
>
> The comment is quite instructive and reasonable, but I see a difference in
> the comment and in the real implementation.
> The comment say: "there must be a contained package that refers to the
> exported package for it to make use importing that package"
> But the implementation do:
> // private packages = contained - exported.
> Set<String> privatePackages = new HashSet<String>(contained.keySet());
> privatePackages.removeAll(exports.keySet());
>
> The implementation do not take care of "contained" packages but only looks
> for "private" packages (that is contained - exported).
>
> In both of my use cases, as I export everything, contained == exported so
> I have no private packages and therefore, not a single exported package is
> also automatically imported.
>
> So finally the question, what is the reasonning to restrict to private
> packages instead of contained packages ?
>
> I may agree that for the library wrapping use case, no substitution is not
> necessarily bad, as if 2 exported packages are equivalent, only the first
> one will be wired to (except if there is a Require-Bundle for this exact
> Bundle).
> But for the other case, I really want my api packages to be also imported,
> well that's an API ...
>
> Thanks
> --Guillaume_______________________________________________
> OSGi Developer Mail List
> [email protected]
> https://mail.osgi.org/mailman/listinfo/osgi-dev
>
>
> _______________________________________________
> OSGi Developer Mail List
> [email protected]
> https://mail.osgi.org/mailman/listinfo/osgi-dev
>
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to