Package com.helger.commons.lang
Class ServiceLoaderHelper
- java.lang.Object
-
- com.helger.commons.lang.ServiceLoaderHelper
-
@Immutable public final class ServiceLoaderHelper extends Object
ServiceLoaderhelper class.- Author:
- boris, Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static AnnotationUsageCacheCACHE_IMPLEMENTATIONstatic AnnotationUsageCacheCACHE_INTERFACE
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <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 Detail
-
CACHE_INTERFACE
public static final AnnotationUsageCache CACHE_INTERFACE
-
CACHE_IMPLEMENTATION
public static final AnnotationUsageCache CACHE_IMPLEMENTATION
-
-
Method Detail
-
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
@Nullable public static <T> T getFirstSPIImplementation(@Nonnull Class<T> aSPIClass)
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.
-
-