Package org.apache.lucene.util
Class NamedSPILoader<S extends NamedSPILoader.NamedSPI>
- java.lang.Object
-
- org.apache.lucene.util.NamedSPILoader<S>
-
- All Implemented Interfaces:
java.lang.Iterable<S>
public final class NamedSPILoader<S extends NamedSPILoader.NamedSPI> extends java.lang.Object implements java.lang.Iterable<S>
Helper class for loading named SPIs from classpath (e.g. Codec, PostingsFormat).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
NamedSPILoader.NamedSPI
Interface to supportlookup(String)
by name.
-
Constructor Summary
Constructors Constructor Description NamedSPILoader(java.lang.Class<S> clazz)
NamedSPILoader(java.lang.Class<S> clazz, java.lang.ClassLoader classloader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Set<java.lang.String>
availableServices()
static void
checkServiceName(java.lang.String name)
Validates that a service name meets the requirements ofNamedSPILoader.NamedSPI
java.util.Iterator<S>
iterator()
S
lookup(java.lang.String name)
void
reload(java.lang.ClassLoader classloader)
Reloads the internal SPI list from the givenClassLoader
.
-
-
-
Method Detail
-
reload
public void reload(java.lang.ClassLoader classloader)
Reloads the internal SPI list from the givenClassLoader
. 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(java.lang.String name)
Validates that a service name meets the requirements ofNamedSPILoader.NamedSPI
-
lookup
public S lookup(java.lang.String name)
-
availableServices
public java.util.Set<java.lang.String> availableServices()
-
iterator
public java.util.Iterator<S> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<S extends NamedSPILoader.NamedSPI>
-
-