/** * Uses the {@link ServiceLoader} to load all SPI implementations of the * passed class and return only the first instance. * * @param aSPIClass * The SPI interface class. May not be <code>null</code>. * @param aClassLoader * The class loader to use for the SPI loader. May not be * <code>null</code>. * @return A collection of all currently available plugins. Never * <code>null</code>. */ @Nullable public static <T> T getFirstSPIImplementation (@Nonnull final Class <T> aSPIClass, @Nonnull final ClassLoader aClassLoader) { return getFirstSPIImplementation (aSPIClass, aClassLoader, null); }
/** * Uses the {@link ServiceLoader} to load all SPI implementations of the * passed class and return only the first instance. * * @param aSPIClass * The SPI interface class. May not be <code>null</code>. * @return A collection of all currently available plugins. Never * <code>null</code>. */ @Nullable public static <T> T getFirstSPIImplementation (@Nonnull final Class <T> aSPIClass) { return getFirstSPIImplementation (aSPIClass, _getDefaultClassLoader (), null); }
/** * Uses the {@link ServiceLoader} to load all SPI implementations of the * passed class and return only the first instance. * * @param aSPIClass * The SPI interface class. May not be <code>null</code>. * @param aLogger * An optional logger to use. May be <code>null</code>. * @return A collection of all currently available plugins. Never * <code>null</code>. */ @Nullable public static <T> T getFirstSPIImplementation (@Nonnull final Class <T> aSPIClass, @Nullable final Logger aLogger) { return getFirstSPIImplementation (aSPIClass, _getDefaultClassLoader (), aLogger); }