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

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>
T`
`newFactoryClassInstance(Class<T> clazz, Map<String,String> args)`
Creates a new instance of the given `AbstractAnalysisFactory` 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 given `ClassLoader`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### AnalysisSPILoader

public AnalysisSPILoader(Class<S> clazz)

### AnalysisSPILoader

public AnalysisSPILoader(Class<S> clazz, ClassLoader classloader)

## Method Details

### 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 (e.g., from `availableServices()`,...) 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

public S newInstance(String name, Map<String,String> args)

### lookupClass

public Class<? extends S> lookupClass(String name)

### availableServices

public Set<String> 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 given `AbstractAnalysisFactory` by invoking the constructor, passing the given argument map.