Class NamedSPILoader<S extends NamedSPILoader.NamedSPI>

  • All Implemented Interfaces:
    Iterable<S>

    public final class NamedSPILoader<S extends NamedSPILoader.NamedSPI>
    extends Object
    implements Iterable<S>
    Helper class for loading named SPIs from classpath (e.g. Codec, PostingsFormat).
    NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
    • Constructor Detail

      • NamedSPILoader

        public NamedSPILoader​(Class<S> clazz)
      • NamedSPILoader

        public NamedSPILoader​(Class<S> clazz,
                              ClassLoader classloader)
    • Method Detail

      • reload

        public void reload​(ClassLoader classloader)
        Reloads the internal SPI list from the given ClassLoader. Changes to the service list are visible after the method ends, all iterators (iterator(),...) stay consistent.

        NOTE: Only new service providers are added, existing ones are never removed or replaced.

        This method is expensive and should only be called for discovery of new service providers on the given classpath/classloader!

      • checkServiceName

        public static void checkServiceName​(String name)
        Validates that a service name meets the requirements of NamedSPILoader.NamedSPI
      • lookup

        public S lookup​(String name)
      • availableServices

        public Set<String> availableServices()