/** * Uses the {@link ServiceLoader} to load all SPI implementations of the * passed class * * @param aSPIClass * The SPI interface class. May not be <code>null</code>. * @return A list of all currently available plugins */ @Nonnull @ReturnsMutableCopy public static <T> List <T> getAllSPIImplementations (@Nonnull final Class <T> aSPIClass) { return getAllSPIImplementations (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>. * @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); }
private EqualsImplementationRegistry () { // Register all implementations via SPI for (final IEqualsImplementationRegistrarSPI aRegistrar : ServiceLoaderUtils.getAllSPIImplementations (IEqualsImplementationRegistrarSPI.class)) aRegistrar.registerEqualsImplementations (this); }
/** * 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); }
private HashCodeImplementationRegistry () { // Register all implementations via SPI for (final IHashCodeImplementationRegistrarSPI aRegistrar : ServiceLoaderUtils.getAllSPIImplementations (IHashCodeImplementationRegistrarSPI.class)) aRegistrar.registerHashCodeImplementations (this); }
/** * Uses the {@link ServiceLoader} to load all SPI implementations of the * passed class * * @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 list of all currently available plugins */ @Nonnull @ReturnsMutableCopy public static <T> List <T> getAllSPIImplementations (@Nonnull final Class <T> aSPIClass, @Nullable final Logger aLogger) { return getAllSPIImplementations (aSPIClass, _getDefaultClassLoader (), aLogger); }
/** * 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); }
/** * Uses the {@link ServiceLoader} to load all SPI implementations of the * passed class * * @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 list of all currently available plugins */ @Nonnull @ReturnsMutableCopy public static <T> List <T> getAllSPIImplementations (@Nonnull final Class <T> aSPIClass, @Nonnull final ClassLoader aClassLoader) { return getAllSPIImplementations (aSPIClass, aClassLoader, null); }
final List <T> aAll = getAllSPIImplementations (aSPIClass, aClassLoader, aRealLogger); if (aAll.isEmpty ())
/** * Reinitialize all protocols. Adds all {@link EURLProtocol} values and * invokes all SPI implementations. */ public static void reinitialize () { s_aRWLock.writeLock ().lock (); try { s_aProtocols.clear (); // Add all default protocols for (final EURLProtocol aProtocol : EURLProtocol.values ()) s_aProtocols.put (aProtocol.getProtocol (), aProtocol); // Load all SPI implementations for (final IURLProtocolRegistrarSPI aRegistrar : ServiceLoaderUtils.getAllSPIImplementations (IURLProtocolRegistrarSPI.class)) { s_aLogger.info ("Registering custom URL protocols of " + aRegistrar.getClass ().getCanonicalName () + "..."); final Set <? extends IURLProtocol> aURLProtocols = aRegistrar.getProtocols (); if (aURLProtocols != null) for (final IURLProtocol aSPIProtocol : aURLProtocols) registerProtocol (aSPIProtocol); } } finally { s_aRWLock.writeLock ().unlock (); } }