You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by "Van Geertruy, Michael" <mv...@NCIINC.com> on 2010/08/20 21:15:47 UTC

Importing and Exporting a bundle's packages

I just read excellent tutorial at http://felix.apache.org/site/apache-felix-osgi-faq.html, and have a question.
 
My osgi application is composed of 124 bundles when deployed in Karaf, if I deploy all dependent .jars as thier own bundles. When I only put an asterisk (*) in the <Export-Package> tag of the maven-bundle-plugin, I noticed the following actions occured:
1) all dependent jars were unpacked and packaged inside of my application's bundle,
2) the "Import-Package" and "Export-Package" referred to all of the new packages in my app's bundle, including those of my application.
 
Now that's all good, because it should decrease the bundles I'll need to deploy from 124 down to 1, and it will make my features.xml file much smaller.  However, when deploying the new bundle inside of Karaf (1.4.0), I got constraint violations for all of the items in my Import-Package portion of the MANIFEST.MF file. I guess imports get resolved before anything is exported.  
 
Is there a way to keep the functionality listed above, and have karaf recognize that my package already contains the packages it needs, and doesn't need to look in OSGi for them?  The answer would seem to be to do something like
<Import-Package>!*</Import-Package>, which appears to be contrary to OSGI.
 
So, my question is, is there a preferred way to accomplish this?
 
Mike Van, PMP, CSM, WTF?
################################################################################
If you have received this message in error, please contact the sender
immediately and be aware that the use, copying, or dissemination of 
this information is prohibited. This email transmission contains 
information from NCI Information Systems, Inc. that may be considered 
privileged or confidential and is intended solely for the named 
recipient.
################################################################################

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Importing and Exporting a bundle's packages

Posted by "Richard S. Hall" <he...@ungoverned.org>.
  On 8/20/10 15:15, Van Geertruy, Michael wrote:
> I just read excellent tutorial at http://felix.apache.org/site/apache-felix-osgi-faq.html, and have a question.
>
> My osgi application is composed of 124 bundles when deployed in Karaf, if I deploy all dependent .jars as thier own bundles. When I only put an asterisk (*) in the<Export-Package>  tag of the maven-bundle-plugin, I noticed the following actions occured:
> 1) all dependent jars were unpacked and packaged inside of my application's bundle,
> 2) the "Import-Package" and "Export-Package" referred to all of the new packages in my app's bundle, including those of my application.
>
> Now that's all good, because it should decrease the bundles I'll need to deploy from 124 down to 1, and it will make my features.xml file much smaller.  However, when deploying the new bundle inside of Karaf (1.4.0), I got constraint violations for all of the items in my Import-Package portion of the MANIFEST.MF file. I guess imports get resolved before anything is exported.
>
> Is there a way to keep the functionality listed above, and have karaf recognize that my package already contains the packages it needs, and doesn't need to look in OSGi for them?  The answer would seem to be to do something like
> <Import-Package>!*</Import-Package>, which appears to be contrary to OSGI.
>
> So, my question is, is there a preferred way to accomplish this?

It is likely that you don't need to import everything that you export, 
but you'd have to look at each export on a case-by-case basis to 
determine what makes sense, which would probably be no fun. The newer 
versions of BND have some built-in heuristics for determine when to 
import what you export, but unfortunately we're still waiting for it to 
be put into a maven repo so it can be integrated into maven-bundle-plugin.

If I had to guess, I'd imagine that your bundle exports some packages 
that the system bundle also exports and your bundle gets into conflicts 
this way. You could look for this case and try to fix it surgically by 
changing how it imports the involved packages. The simpler approach if 
you just want to get it working is to do use "*;-noimport:=true" for 
your export, then BND won't generate imports for what you export.

However, it seems that by lumping all bundles into one super bundle, you 
are sort of defeating the purpose of using OSGi in the first place, no?

-> richard

>
> Mike Van, PMP, CSM, WTF?
> ################################################################################
> If you have received this message in error, please contact the sender
> immediately and be aware that the use, copying, or dissemination of
> this information is prohibited. This email transmission contains
> information from NCI Information Systems, Inc. that may be considered
> privileged or confidential and is intended solely for the named
> recipient.
> ################################################################################
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org