Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

Apply patches in NUTCH-194.

Andrzej Bialeckie0dffdcf5204
diff --git a/src/java/org/apache/nutch/plugin/Plugin.java b/src/java/org/apache/nutch/plugin/Plugin.java
index 66588a6dd..7f82406af 100644
--- a/src/java/org/apache/nutch/plugin/Plugin.java
+++ b/src/java/org/apache/nutch/plugin/Plugin.java
@@ -15,6 +15,9 @@
* limitations under the License.
*/
package org.apache.nutch.plugin;
+
+import org.apache.nutch.util.NutchConf;
+
/**
* A nutch-plugin is an container for a set of custom logic that provide
* extensions to the nutch core functionality or another plugin that provides an
@@ -37,12 +40,15 @@ package org.apache.nutch.plugin;
*/
public class Plugin {
private PluginDescriptor fDescriptor;
+ protected NutchConf nutchConf;
+
/**
* Constructor
*
*/
- public Plugin(PluginDescriptor pDescriptor) {
+ public Plugin(PluginDescriptor pDescriptor, NutchConf nutchConf) {
setDescriptor(pDescriptor);
+ this.nutchConf = nutchConf;
}
/**
* Will be invoked until plugin start up. Since the nutch-plugin system use
diff --git a/src/java/org/apache/nutch/plugin/PluginRepository.java b/src/java/org/apache/nutch/plugin/PluginRepository.java
index f11ff2eb1..f78c15378 100644
--- a/src/java/org/apache/nutch/plugin/PluginRepository.java
+++ b/src/java/org/apache/nutch/plugin/PluginRepository.java
@@ -56,6 +56,8 @@ public class PluginRepository {
private HashMap fActivatedPlugins;
+ private NutchConf nutchConf;
+
public static final Logger LOG = LogFormatter
.getLogger("org.apache.nutch.plugin.PluginRepository");
@@ -67,6 +69,7 @@ public class PluginRepository {
public PluginRepository(NutchConf nutchConf) throws RuntimeException {
fActivatedPlugins = new HashMap();
fExtensionPoints = new HashMap();
+ this.nutchConf = nutchConf;
this.auto = nutchConf.getBoolean("plugin.auto-activation", true);
String[] pluginFolders = nutchConf.getStrings("plugin.folders");
PluginManifestParser manifestParser = new PluginManifestParser(nutchConf, this);
@@ -280,9 +283,9 @@ public class PluginRepository {
Class pluginClass = loader.loadClass(pDescriptor
.getPluginClass());
Constructor constructor = pluginClass
- .getConstructor(new Class[] { PluginDescriptor.class });
+ .getConstructor(new Class[] { PluginDescriptor.class, NutchConf.class });
Plugin plugin = (Plugin) constructor
- .newInstance(new Object[] { pDescriptor });
+ .newInstance(new Object[] { pDescriptor, this.nutchConf });
plugin.startUp();
fActivatedPlugins.put(pDescriptor.getPluginId(), plugin);
return plugin;
diff --git a/src/java/org/apache/nutch/searcher/QueryFilters.java b/src/java/org/apache/nutch/searcher/QueryFilters.java
index 375e41e6a..dcde25eda 100644
--- a/src/java/org/apache/nutch/searcher/QueryFilters.java
+++ b/src/java/org/apache/nutch/searcher/QueryFilters.java
@@ -58,6 +58,8 @@ public class QueryFilters {
if (point == null)
throw new RuntimeException(QueryFilter.X_POINT_ID + " not found.");
Extension[] extensions = point.getExtensions();
+ FIELD_NAMES = new HashSet();
+ RAW_FIELD_NAMES = new HashSet();
QueryFilter[] filters = new QueryFilter[extensions.length];
for (int i = 0; i < extensions.length; i++) {
Extension extension = extensions[i];
@@ -69,11 +71,9 @@ public class QueryFilters {
continue;
}
filters[i] = (QueryFilter) extension.getExtensionInstance();
- FIELD_NAMES = new HashSet();
FIELD_NAMES.addAll(fieldNames);
FIELD_NAMES.addAll(rawFieldNames);
nutchConf.setObject("FIELD_NAMES", FIELD_NAMES);
- RAW_FIELD_NAMES = new HashSet();
RAW_FIELD_NAMES.addAll(rawFieldNames);
nutchConf.setObject("RAW_FIELD_NAMES", RAW_FIELD_NAMES);
}
diff --git a/src/test/org/apache/nutch/plugin/SimpleTestPlugin.java b/src/test/org/apache/nutch/plugin/SimpleTestPlugin.java
index 8e3eccd26..6bd124279 100644
--- a/src/test/org/apache/nutch/plugin/SimpleTestPlugin.java
+++ b/src/test/org/apache/nutch/plugin/SimpleTestPlugin.java
@@ -17,6 +17,8 @@
package org.apache.nutch.plugin;
+import org.apache.nutch.util.NutchConf;
+
/**
* Simple Test plugin
*
@@ -26,10 +28,11 @@ public class SimpleTestPlugin extends Plugin {
/**
* @param pDescriptor
+ * @param nutchConf
*/
- public SimpleTestPlugin(PluginDescriptor pDescriptor) {
+ public SimpleTestPlugin(PluginDescriptor pDescriptor, NutchConf nutchConf) {
- super(pDescriptor);
+ super(pDescriptor, nutchConf);
}
/*