Package org.apache.solr.util.plugin
Class AbstractPluginLoader<T>
- java.lang.Object
-
- org.apache.solr.util.plugin.AbstractPluginLoader<T>
-
- Direct Known Subclasses:
FieldTypePluginLoader
,MapPluginLoader
,NamedListPluginLoader
public abstract class AbstractPluginLoader<T> extends Object
An abstract super class that manages standard solr-style plugin configuration.- Since:
- solr 1.3
-
-
Constructor Summary
Constructors Constructor Description AbstractPluginLoader(String type, Class<T> pluginClassType)
AbstractPluginLoader(String type, Class<T> pluginClassType, boolean preRegister, boolean requireName)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected T
create(SolrResourceLoader loader, String name, String className, Node node)
Create a plugin from an XML configuration.protected String[]
getDefaultPackages()
Where to look for classesprotected abstract void
init(T plugin, Node node)
Initialize the plugin.T
load(SolrResourceLoader loader, NodeList nodes)
Initializes and registers each plugin in the list.T
loadSingle(SolrResourceLoader loader, Node node)
Initializes and registers a single plugin.protected abstract T
register(String name, T plugin)
Register a plugin with a given name.
-
-
-
Constructor Detail
-
AbstractPluginLoader
public AbstractPluginLoader(String type, Class<T> pluginClassType, boolean preRegister, boolean requireName)
- Parameters:
type
- is the 'type' name included in error messages.preRegister
- if true, this will first register all Plugins, then it will initialize them.
-
-
Method Detail
-
getDefaultPackages
protected String[] getDefaultPackages()
Where to look for classes
-
create
protected T create(SolrResourceLoader loader, String name, String className, Node node) throws Exception
Create a plugin from an XML configuration. Plugins are defined using:<plugin name="name1" class="solr.ClassName"> ... </plugin>
- Parameters:
name
- - The registered name. In the above example: "name1"className
- - class name for requested plugin. In the above example: "solr.ClassName"node
- - the XML node defining this plugin- Throws:
Exception
-
register
protected abstract T register(String name, T plugin) throws Exception
Register a plugin with a given name.- Returns:
- The plugin previously registered to this name, or null
- Throws:
Exception
-
init
protected abstract void init(T plugin, Node node) throws Exception
Initialize the plugin.- Parameters:
plugin
- - the plugin to initializenode
- - the XML node defining this plugin- Throws:
Exception
-
load
public T load(SolrResourceLoader loader, NodeList nodes)
Initializes and registers each plugin in the list. Given a NodeList from XML in the form:<plugins> <plugin name="name1" class="solr.ClassName" > ... </plugin> <plugin name="name2" class="solr.ClassName" > ... </plugin> </plugins>
<plugin name="name2" class="solr.ClassName" default="true">
-
loadSingle
public T loadSingle(SolrResourceLoader loader, Node node)
Initializes and registers a single plugin. Given a NodeList from XML in the form:<plugin name="name1" class="solr.ClassName" > ... </plugin>
-
-