Hello,

Having both an export and an import declared for a package is not an error, and 
the behaviour is explicitly defined in the OSGi core specification. The process 
of importing and exporting a package is known as making the package 
"substitutable".

When you have both an export and an import the OSGi framework gets to decide 
whether your bundle will use its own copy of the package and export it to the 
outside world, or whether it will import the package from another bundle and 
hide both the export and the internal copy.

In fact I would usually advise not disabling this behaviour. Having a 
substitutable package is desirable in many cases! If, for example, you have two 
bundles that expose the same service interface and they both export, but do not 
import, the API package then a client bundle can never use both service 
implementations (it will only be wired to one of the exported packages)!

As with many things context is king - more information about what is in the 
package and how it is used is needed before a specific recommendation can be 
made for this bundle.

Regards,

Tim Ward

OSGi IoT EG Chair

> On 29 Mar 2016, at 09:25, CLEMENT Jean-Philippe 
> <[email protected]> wrote:
> 
> Hello,
> 
> For sure if the import is not necessary, then remove it :)
> 
> You may "ask" maven-bundle-plugin not to generate the import or you may put 
> the dependency generating the import as optional.
> 
> JP
> 
> -----Message d'origine-----
> De : asookazian2 [mailto:[email protected]] 
> Envoyé : mardi 29 mars 2016 00:55
> À : [email protected]
> Objet : importing and exporting same package in same bundle
> 
> what are the side-effects/consequences of importing and exporting same 
> package in same bundle?  Is this normal or bad practice and if we are doing 
> this in our manifest.mf, how do we correct this in the pom.xml and 
> maven-bundle-plugin config/instructions?  thx.
> 
> 
> 
> --
> View this message in context: 
> http://karaf.922171.n3.nabble.com/importing-and-exporting-same-package-in-same-bundle-tp4046020.html
> Sent from the Karaf - User mailing list archive at Nabble.com.

Reply via email to