public class ServiceLoaderOSGiWrapper extends Object
OSGi is known to break the ServiceLoader mechanism. Unfortunately, we have not been able to make the standard based solution based on Ares SPI-Fly work. Therefore we have created this wrapper that detects whether the class has been loaded with OSGi. If not, uses the standard ServiceLoader. If so, uses introspection to access the OSGi framework and replicate the functionality.
Note that the implementation on OSGi will not give all the nice debugging information that the standard ServiceLoader implementation does. It also is not optimized: makes heavy use of introspection and does not use lazy initialization. It's essentially a hack to make things to work.
Constructor and Description |
---|
ServiceLoaderOSGiWrapper() |
Modifier and Type | Method and Description |
---|---|
static <T> Iterable<T> |
load(Class<T> serviceClazz) |
static <T> void |
load(Class<T> serviceClazz,
Logger log,
java.util.function.Consumer<T> consumer) |
public static <T> void load(Class<T> serviceClazz, Logger log, java.util.function.Consumer<T> consumer)
Copyright © 2015. All rights reserved.