You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by asookazian2 <as...@gmail.com> on 2016/03/29 00:54:30 UTC

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.

Re: importing and exporting same package in same bundle

Posted by Tim Ward <ti...@paremus.com>.
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 <je...@fr.thalesgroup.com> 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:asookazian@gmail.com] 
> Envoyé : mardi 29 mars 2016 00:55
> À : user@karaf.apache.org
> 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.

RE: importing and exporting same package in same bundle

Posted by CLEMENT Jean-Philippe <je...@fr.thalesgroup.com>.
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:asookazian@gmail.com] 
Envoyé : mardi 29 mars 2016 00:55
À : user@karaf.apache.org
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.