public abstract class AbstractPluginLoader<T> extends Object
Modifier and Type | Field and Description |
---|---|
static org.slf4j.Logger |
log |
Constructor and Description |
---|
AbstractPluginLoader(String type,
Class<T> pluginClassType) |
AbstractPluginLoader(String type,
Class<T> pluginClassType,
boolean preRegister,
boolean requireName) |
Modifier and Type | Method and 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 classes
|
protected 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.
|
public AbstractPluginLoader(String type, Class<T> pluginClassType, boolean preRegister, boolean requireName)
type
- is the 'type' name included in error messages.preRegister
- if true, this will first register all Plugins, then it will initialize them.protected String[] getDefaultPackages()
protected T create(SolrResourceLoader loader, String name, String className, Node node) throws Exception
<plugin name="name1" class="solr.ClassName">
...
</plugin>
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 pluginException
protected abstract T register(String name, T plugin) throws Exception
Exception
protected abstract void init(T plugin, Node node) throws Exception
plugin
- - the plugin to initializenode
- - the XML node defining this pluginException
public T load(SolrResourceLoader loader, NodeList nodes)
<plugins>
<plugin name="name1" class="solr.ClassName" >
...
</plugin>
<plugin name="name2" class="solr.ClassName" >
...
</plugin>
</plugins>
This will initialize and register each plugin from the list. A class will
be generated for each class name and registered to the given name.
If 'preRegister' is true, each plugin will be registered *before* it is initialized
This may be useful for implementations that need to inspect other registered
plugins at startup.
One (and only one) plugin may declare itself to be the 'default' plugin using:
<plugin name="name2" class="solr.ClassName" default="true">
If a default element is defined, it will be returned from this function.public T loadSingle(SolrResourceLoader loader, Node node)
<plugin name="name1" class="solr.ClassName" > ... </plugin>
This will initialize and register a single plugin. A class will be
generated for the plugin and registered to the given name.
If 'preRegister' is true, the plugin will be registered *before* it is
initialized This may be useful for implementations that need to inspect
other registered plugins at startup.
The created class for the plugin will be returned from this function.Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.