Thanks answering me but still not working i didn't even have a clue of
wich bundle need to be modified the one from wich the code is called i
suppose any other proposition ?
Le 26/03/2024 à 12:07, Steinar Bang a écrit :
Michael Elbaz <[email protected]>:
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
FWIW SPI-fly and SPI is something I've used, but it is a place where
I've never been quite clear about why and how it works.
One place I use it is with my Liquibase karaf feature
https://github.com/steinarb/liquibase-karaf-feature?tab=readme-ov-file#using-liquibase-from-osgi-bundles
Requiring services only needs to be done once for each karaf instance
(i.e. once for each Java VM running), I think...? Maybe...?
The requirements haven't been consistent across the applications using
liquibase even though they are very similar..
Another place I've used it is when using the TwelveMonkeys Image
manipulation library, which plugs into the SPI-based ImageIO support of
the Java runtime.
Here I used a DS (Declarative Services) component to load TwelveMonkeys
and catch the TwelveMonkeys services and register them with ImageIO.
https://github.com/steinarb/oldalbum/blob/master/oldalbum.backend.imageio/pom.xml#L115
https://github.com/steinarb/oldalbum/blob/master/oldalbum.backend.imageio/src/main/java/no/priv/bang/oldalbum/backend/imageio/ImageioSpiRegistration.java#L17
After this (in my own head: clever) trick, the ImageIO API of the runtime
works as it would outside of OSGi, but with the TwelveMonkeys plugins in
place of the default image manipulation code.
So, not really help, but at least two working examples of the use of
SPI-fly... :-)
- Steinar