Package org.apache.lucene.analysis
Class AnalysisSPILoader<S extends AbstractAnalysisFactory>
- java.lang.Object
-
- org.apache.lucene.analysis.AnalysisSPILoader<S>
-
public final class AnalysisSPILoader<S extends AbstractAnalysisFactory> extends Object
Helper class for loading named SPIs from classpath (e.g. Tokenizers, TokenStreams).- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
-
Constructor Summary
Constructors Constructor Description AnalysisSPILoader(Class<S> clazz)
AnalysisSPILoader(Class<S> clazz, ClassLoader classloader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<String>
availableServices()
Class<? extends S>
lookupClass(String name)
static String
lookupSPIName(Class<? extends AbstractAnalysisFactory> service)
Looks up SPI name (static "NAME" field) with appropriate modifiers.static <T extends AbstractAnalysisFactory>
TnewFactoryClassInstance(Class<T> clazz, Map<String,String> args)
Creates a new instance of the givenAbstractAnalysisFactory
by invoking the constructor, passing the given argument map.S
newInstance(String name, Map<String,String> args)
void
reload(ClassLoader classloader)
Reloads the internal SPI list from the givenClassLoader
.
-
-
-
Constructor Detail
-
AnalysisSPILoader
public AnalysisSPILoader(Class<S> clazz, ClassLoader classloader)
-
-
Method Detail
-
reload
public void reload(ClassLoader classloader)
Reloads the internal SPI list from the givenClassLoader
. Changes to the service list are visible after the method ends, all iterators (e.g., fromavailableServices()
,...) 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!
-
lookupSPIName
public static String lookupSPIName(Class<? extends AbstractAnalysisFactory> service) throws NoSuchFieldException, IllegalAccessException, IllegalStateException
Looks up SPI name (static "NAME" field) with appropriate modifiers. Also it must be a String class and declared in the concrete class.- Returns:
- the SPI name
- Throws:
NoSuchFieldException
- - if the "NAME" field is not defined.IllegalAccessException
- - if the "NAME" field is inaccessible.IllegalStateException
- - if the "NAME" field does not have appropriate modifiers or isn't a String field.
-
newFactoryClassInstance
public static <T extends AbstractAnalysisFactory> T newFactoryClassInstance(Class<T> clazz, Map<String,String> args)
Creates a new instance of the givenAbstractAnalysisFactory
by invoking the constructor, passing the given argument map.
-
-