-
Hi guys! I'm creating a extension to define ratio based on attributes. The strucutre of the Samplers, ConfigurableSamplerProvider, and others are working fine. Now, I'm trying to create some classes to group some filter rules and everything is working fine, except for the part to get the implementations of MyInterface. I'm using Goolge AutoService to help to register the classes and trying to get those implementations using ServiceLoader. Below is the structured code :
In the console, I have "test" string but none "My Interface XXX" , and the method getName() is called, but Otel works fine getting MySampler. I also tried to use SafeServiceLoader, with Thread.currentThread().getContextClassLoader() as a classesLoader parameter, but In summary, i'm not able to use Thank you ! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I think your hunch is correct, but instead of |
Beta Was this translation helpful? Give feedback.
-
That made it ! |
Beta Was this translation helpful? Give feedback.
I think your hunch is correct, but instead of
Thread.currentThread().getContextClassLoader()
, which probably returns null, you should be passingthis.getClass().getClassLoader()
to theServiceLoader.load(...)
.