Nutch 1.0 source code analysis [3] Plugin (2), nutchplugin
Nutch 1.0 source code analysis [3] Plugin (2)
From: http://c.tieba.baidu.com/p/3439551436
In the URLNormalizers constructor, one sentence is not read:
This. ExtensionPoint = PluginRepository.Get(Conf). getExtensionPoint (
URLNormalizer.X_POINT_ID);
Let's take a look at the PluginRepository. get function:
Public static synchronizedPluginRepository get (Configuration conf ){
PluginRepository result =CACHE. Get (conf );
If(Result =Null){
Result =NewPluginRepository (conf );
CACHE. Put (conf, result );
}
ReturnResult;
}
First try to get from the CACHE. If it has not been cached, call the inrepository constructor:
PublicPluginRepository (Configuration conf)ThrowsRuntimeException {
FActivatedPlugins =NewHashMap <String, Plugin> ();
FExtensionPoints =NewHashMap <String, ExtensionPoint> ();
This. Conf = conf;
This. Auto = conf. getBoolean ("plugin. auto-activation ",True);
String [] pluginFolders = conf. getStrings ("plugin. folders ");
PluginManifestParsermanifestParser =NewPluginManifestParser (conf,
This);
Map <String, PluginDescriptor> allPlugins = manifestParser
. ParsePluginFolder (pluginFolders );
Pattern excludes = Pattern.Compile(Conf. get ("plugin. excludes ",""));
Pattern occurrence des = Pattern.Compile(Conf. get ("plugin. includes ",""));
Map <String, PluginDescriptor> filteredPlugins = filter (excludes,
Includes, allPlugins );
FRegisteredPlugins = getDependencyCheckedPlugins (filteredPlugins,
This. Auto? AllPlugins: filteredPlugins );
InstallExtensionPoints (fRegisteredPlugins );
Try{
InstallExtensions (fRegisteredPlugins );
}Catch(PluginRuntimeException e ){
LOG. Fatal (e. toString ());
ThrownewRuntimeException (e. getMessage ());
}
DisplayStatus ();
}
Copy the following description in "analysis of the Nutch plug-in system:
1. plugin. folders: directory where the plug-in is located. The default location is under the plugins directory.
<Property>
<Name> plugin. folders </name>
<Value> plugins </value>
</Property>
2. plugin. auto-activation: whether to enable the plug-in automatically when it is configured as a filter (I .e., not loaded) but dependent on other plug-ins. The default value is true.
<Property>
<Name> plugin. auto-activation </name>
<Value> true </value>
</Property>
3. plugin. Des: List of plug-in names to be included, which can be defined using regular expressions.
<Property>