Package org.apache.lucene.analysis
Class AnalysisSPILoader<S extends AbstractAnalysisFactory>
java.lang.Object
org.apache.lucene.analysis.AnalysisSPILoader<S>
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
ConstructorDescriptionAnalysisSPILoader
(Class<S> clazz) AnalysisSPILoader
(Class<S> clazz, ClassLoader classloader) -
Method Summary
Modifier and TypeMethodDescriptionlookupClass
(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.newInstance
(String name, Map<String, String> args) void
reload
(ClassLoader classloader) Reloads the internal SPI list from the givenClassLoader
.
-
Constructor Details
-
AnalysisSPILoader
-
AnalysisSPILoader
-
-
Method Details
-
reload
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!
-
newInstance
-
lookupClass
-
availableServices
-
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.
-