3 Replies Latest reply on May 28, 2010 3:42 AM by walter.accantelli

    How to import class (bean) from an other bundle

    walter.accantelli

      Hi all,

      I have 2 osgi bundle (osgi-import-sample1 and osgi-export-sample1) and this is what I would like to do:

      1) export a class (called BeanToExport) from bundle osgi-export-sample1

      2) import/use that class (BeanToExport) in bundle osgi-import-sample1

       

      This is what I've done:

      1) In osgi-export-sample1, I've created a simple Bean (com.bundleexport.beans.BeanToExport) that implements InitializingBean and DisposableBean and it's exported with the following configuration in pom.xml:

       

                <Export-Package>

                     com.bundleexport.beans.BeanToExport

                com.bundleexport</groupId>

                     <artifactId>osgi-export-sample1</artifactId>

                     <version>0.1</version>

                     <type>bundle</type>

                     <scope>compile</scope>

                </dependency>

                ....

       

                <Import-Package>

                     *,

                     ...,

                     com.bundleexport.beans

                </Import-Package>

       

      After that, when I try to use the BeanToExport inside osgi-import-sample1, that class is not visible - I cannot import/use that class in osgi-import-sample1.

       

      Is there something I miss or I done wrong?

       

      I've attach the source code, hope this help to undestand.