The producer Bundle A pom build

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>5.1.9</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                    <Bundle-Version>${project.version}</Bundle-Version>
                    <Import-Package>
                        javax.net*,
                        javax.security*,
                        javax.crypto*,
                    </Import-Package>
                    <Export-Package>
                        io.vertx.*,
                        io.reactivex.*,
                        io.netty.*,
                        org.reactivestreams.*,
                        org.apache.qpid.*,
                        com.fasterxml.*,
                    </Export-Package>
<!-- Trying to make SPI work --> <_exportcontents/>
                    <Private-Package/>
                    
<Embed-Dependency>*;scope=compile;inline=false</Embed-Dependency>
                    <SPI-Provider>*</SPI-Provider>
                    <Provide-Capability>
                        osgi.serviceloader;
                        osgi.serviceloader=io.vertx.ext.auth.HashingAlgorithm
                    </Provide-Capability>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
</build>

The consumer Bundle B pom build

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>5.1.9</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <SPI-Consumer>*</SPI-Consumer>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
</build>



Le 26/03/2024 à 21:12, Cesar Garcia a écrit :
Hello,

It could be something like this

The Producer, Bundle A

             <plugin>
                 <groupId>org.apache.felix</groupId>
 <artifactId>maven-bundle-plugin</artifactId>
                 <version>5.1.9</version>
                 <extensions>true</extensions>
                 <configuration>
                     <instructions>
 <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
 <Bundle-Version>${project.version}</Bundle-Version>
 
<Export-Package>com.ceos.grpc.server*;version=${project.version}</Export-Package>
 <Import-Package>*</Import-Package>
* <SPI-Provider>*</SPI-Provider>*
                     </instructions>
                 </configuration>
             </plugin>

The consumer, Bundle B

             <plugin>
                 <groupId>org.apache.felix</groupId>
 <artifactId>maven-bundle-plugin</artifactId>
                 <version>5.1.9</version>
                 <extensions>true</extensions>
                 <configuration>
                     <instructions>
 <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
 <Bundle-Version>${project.version}</Bundle-Version>
 
<Export-Package>com.ceos.grpc.client*;version=${project.version}</Export-Package>
*                         <Import-Package>
 org.apache.karaf.shell*;version="[4,5)",
                             *
                         </Import-Package>
 <SPI-Consumer>*</SPI-Consumer>*
 <Karaf-Commands>com.ceos.grpc.client.command</Karaf-Commands>
                     </instructions>
                 </configuration>
             </plugin>

In this case, Bundle B consumes all the services exported by Bundle A using SPI-Fly.

If you still have problems, you can indicate in the pom that all internal packages are exported. After compilation you should be able to see it in the MANIFEST-INF.

I hope it helps in something,

Kind regards,

El mar, 26 mar 2024 a las 15:21, Michael Elbaz (<[email protected]>) escribió:

    Hello Achim Hello Cesar,

    It's little bit more tricky i have two bundle jar the first one is
    just a bundle with all vertx thing inside, that export vertx
    package to Karaf
    And the second bundle is simple regular OSGI bundle wich call some
    vertx http server, so the point is inside the vertx bundle there
    is one dependencie (transitive dependencie) vertx-auth-common
    that do some SPI and another one that try to use this class so
    eveything happen in this jar/bundle (the vertx one) i don't
    understand in this case if the TCCL is in my second jar ? and if
    not how i need to do to allow vertx discovering this SPI classes ?
    (i off course can't modifie the transitive jar dependencies)

    Thanks :)

    Le 26/03/2024 à 14:07, Cesar Garcia a écrit :
    Hello,

    Definitely for that problem it helps:

    https://aries.apache.org/documentation/modules/spi-fly.html

    You must clearly define in your poms which export services with
    "SPI-Provider: *" or import services with "SPI-Consumer: *", this
    is done in your pom.xml file.

    My grain of sand,

    Greetings

    El mar, 26 mar 2024 a las 6:48, Michael Elbaz
    (<[email protected]>) escribió:

        Hello i use vertx (wraping as a bundle) inside karaf i'm
        facing a
        problem because vertx-auth-common use SPI mecanism internally
        to load
        some classes
        
(https://github.com/eclipse-vertx/vertx-auth/blob/4.5.6/vertx-auth-common/src/main/resources/META-INF/services/io.vertx.ext.auth.HashingAlgorithm)

        internally is use ServiceLoader.load but during runtime the
        classes are
        not found is probably related to TCCL, i was trying apache
        aries Spy Fly
        stuff with no success how i need to do this working thanks



-- *CEOS Automatización, C.A.*
    *GALPON SERVICIO INDUSTRIALES Y NAVALES FA, C.A.,*
    *PISO 1, OFICINA 2, AV. RAUL LEONI, SECTOR GUAMACHITO,*
    *FRENTE A LA ASOCIACION DE GANADEROS,BARCELONA,EDO. ANZOATEGUI
    *
    *Ing. César García*
    *Cel: +58 414-760.98.95
    *
    *Hotline Técnica SIEMENS: 0800 1005080
    *
    *Email: [email protected]
    *




--
*CEOS Automatización, C.A.*
*GALPON SERVICIO INDUSTRIALES Y NAVALES FA, C.A.,*
*PISO 1, OFICINA 2, AV. RAUL LEONI, SECTOR GUAMACHITO,*
*FRENTE A LA ASOCIACION DE GANADEROS,BARCELONA,EDO. ANZOATEGUI
*
*Ing. César García*
*Cel: +58 414-760.98.95
*
*Hotline Técnica SIEMENS: 0800 1005080
*
*Email: [email protected]
*

Reply via email to