Package com.helger.commons.lang
Class ServiceLoaderHelper
java.lang.Object
com.helger.commons.lang.ServiceLoaderHelper
ServiceLoader helper class.- Author:
- boris, Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final AnnotationUsageCachestatic final AnnotationUsageCache -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ICommonsList<T> getAllSPIImplementations(Class<T> aSPIClass) Uses theServiceLoaderto load all SPI implementations of the passed classstatic <T> ICommonsList<T> getAllSPIImplementations(Class<T> aSPIClass, ClassLoader aClassLoader) Uses theServiceLoaderto load all SPI implementations of the passed classstatic <T> ICommonsList<T> getAllSPIImplementations(Class<T> aSPIClass, ClassLoader aClassLoader, org.slf4j.Logger aLogger) Uses theServiceLoaderto load all SPI implementations of the passed classstatic <T> ICommonsList<T> getAllSPIImplementations(Class<T> aSPIClass, org.slf4j.Logger aLogger) Uses theServiceLoaderto load all SPI implementations of the passed classstatic <T> TgetFirstSPIImplementation(Class<T> aSPIClass) Uses theServiceLoaderto load all SPI implementations of the passed class and return only the first instance.static <T> TgetFirstSPIImplementation(Class<T> aSPIClass, ClassLoader aClassLoader) Uses theServiceLoaderto load all SPI implementations of the passed class and return only the first instance.static <T> TgetFirstSPIImplementation(Class<T> aSPIClass, ClassLoader aClassLoader, org.slf4j.Logger aLogger) Uses theServiceLoaderto load all SPI implementations of the passed class and return only the first instance.static <T> TgetFirstSPIImplementation(Class<T> aSPIClass, org.slf4j.Logger aLogger) Uses theServiceLoaderto load all SPI implementations of the passed class and return only the first instance.
-
Field Details
-
CACHE_INTERFACE
-
CACHE_IMPLEMENTATION
-
-
Method Details
-
getAllSPIImplementations
@Nonnull @ReturnsMutableCopy public static <T> ICommonsList<T> getAllSPIImplementations(@Nonnull Class<T> aSPIClass) Uses theServiceLoaderto load all SPI implementations of the passed class- Type Parameters:
T- The implementation type to be loaded- Parameters:
aSPIClass- The SPI interface class. May not benull.- Returns:
- A list of all currently available plugins
-
getAllSPIImplementations
@Nonnull @ReturnsMutableCopy public static <T> ICommonsList<T> getAllSPIImplementations(@Nonnull Class<T> aSPIClass, @Nonnull ClassLoader aClassLoader) Uses theServiceLoaderto load all SPI implementations of the passed class- Type Parameters:
T- The implementation type to be loaded- Parameters:
aSPIClass- The SPI interface class. May not benull.aClassLoader- The class loader to use for the SPI loader. May not benull.- Returns:
- A list of all currently available plugins
-
getAllSPIImplementations
@Nonnull @ReturnsMutableCopy public static <T> ICommonsList<T> getAllSPIImplementations(@Nonnull Class<T> aSPIClass, @Nullable org.slf4j.Logger aLogger) Uses theServiceLoaderto load all SPI implementations of the passed class- Type Parameters:
T- The implementation type to be loaded- Parameters:
aSPIClass- The SPI interface class. May not benull.aLogger- An optional logger to use. May benull.- Returns:
- A list of all currently available plugins
-
getAllSPIImplementations
@Nonnull @ReturnsMutableCopy public static <T> ICommonsList<T> getAllSPIImplementations(@Nonnull Class<T> aSPIClass, @Nonnull ClassLoader aClassLoader, @Nullable org.slf4j.Logger aLogger) Uses theServiceLoaderto load all SPI implementations of the passed class- Type Parameters:
T- The implementation type to be loaded- Parameters:
aSPIClass- The SPI interface class. May not benull.aClassLoader- The class loader to use for the SPI loader. May not benull.aLogger- An optional logger to use. May benull.- Returns:
- A collection of all currently available plugins. Never
null.
-
getFirstSPIImplementation
Uses theServiceLoaderto load all SPI implementations of the passed class and return only the first instance.- Type Parameters:
T- The implementation type to be loaded- Parameters:
aSPIClass- The SPI interface class. May not benull.- Returns:
- A collection of all currently available plugins. Never
null.
-
getFirstSPIImplementation
@Nullable public static <T> T getFirstSPIImplementation(@Nonnull Class<T> aSPIClass, @Nonnull ClassLoader aClassLoader) Uses theServiceLoaderto load all SPI implementations of the passed class and return only the first instance.- Type Parameters:
T- The implementation type to be loaded- Parameters:
aSPIClass- The SPI interface class. May not benull.aClassLoader- The class loader to use for the SPI loader. May not benull.- Returns:
- A collection of all currently available plugins. Never
null.
-
getFirstSPIImplementation
@Nullable public static <T> T getFirstSPIImplementation(@Nonnull Class<T> aSPIClass, @Nullable org.slf4j.Logger aLogger) Uses theServiceLoaderto load all SPI implementations of the passed class and return only the first instance.- Type Parameters:
T- The implementation type to be loaded- Parameters:
aSPIClass- The SPI interface class. May not benull.aLogger- An optional logger to use. May benull.- Returns:
- A collection of all currently available plugins. Never
null.
-
getFirstSPIImplementation
@Nullable public static <T> T getFirstSPIImplementation(@Nonnull Class<T> aSPIClass, @Nonnull ClassLoader aClassLoader, @Nullable org.slf4j.Logger aLogger) Uses theServiceLoaderto load all SPI implementations of the passed class and return only the first instance.- Type Parameters:
T- The implementation type to be loaded- Parameters:
aSPIClass- The SPI interface class. May not benull.aClassLoader- The class loader to use for the SPI loader. May not benull.aLogger- An optional logger to use. May benull.- Returns:
- A collection of all currently available plugins. Never
null.
-