Apache Nutch is an extensible and scalable web crawler
Add a common Pluggable interface to all Extension Points and a package description for plugin
Jerome Charronba372da378d8
diff --git a/src/java/org/apache/nutch/analysis/NutchAnalyzer.java b/src/java/org/apache/nutch/analysis/NutchAnalyzer.javaindex d1c8d6390..6fec6952d 100644--- a/src/java/org/apache/nutch/analysis/NutchAnalyzer.java+++ b/src/java/org/apache/nutch/analysis/NutchAnalyzer.java@@ -22,6 +22,9 @@ import java.io.Reader;import org.apache.lucene.analysis.Analyzer;import org.apache.lucene.analysis.TokenStream;+// Nutch imports+import org.apache.nutch.plugin.Pluggable;+/*** Extension point for analysis.@@ -30,7 +33,8 @@ import org.apache.lucene.analysis.TokenStream;** @author Jérôme Charron*/-public abstract class NutchAnalyzer extends Analyzer {+public abstract class NutchAnalyzer extends Analyzer+ implements Pluggable {/** The name of the extension point. */final static String X_POINT_ID = NutchAnalyzer.class.getName();diff --git a/src/java/org/apache/nutch/clustering/OnlineClusterer.java b/src/java/org/apache/nutch/clustering/OnlineClusterer.javaindex 7f44fe60d..da0eb7c53 100644--- a/src/java/org/apache/nutch/clustering/OnlineClusterer.java+++ b/src/java/org/apache/nutch/clustering/OnlineClusterer.java@@ -16,8 +16,11 @@package org.apache.nutch.clustering;+// Nutch imports+import org.apache.nutch.plugin.Pluggable;import org.apache.nutch.searcher.HitDetails;+/*** An extension point interface for online search results clustering* algorithms.@@ -33,7 +36,7 @@ import org.apache.nutch.searcher.HitDetails;* @author Dawid Weiss* @version $Id: OnlineClusterer.java,v 1.1 2004/08/09 23:23:52 johnnx Exp $*/-public interface OnlineClusterer {+public interface OnlineClusterer extends Pluggable {/** The name of the extension point. */public final static String X_POINT_ID = OnlineClusterer.class.getName();diff --git a/src/java/org/apache/nutch/indexer/IndexingFilter.java b/src/java/org/apache/nutch/indexer/IndexingFilter.javaindex 5c1607167..06620eb39 100644--- a/src/java/org/apache/nutch/indexer/IndexingFilter.java+++ b/src/java/org/apache/nutch/indexer/IndexingFilter.java@@ -16,18 +16,25 @@package org.apache.nutch.indexer;+// Lucene importsimport org.apache.lucene.document.Document;-import org.apache.nutch.parse.Parse;++// Hadoop importsimport org.apache.hadoop.conf.Configurable;+import org.apache.hadoop.io.UTF8;++// Nutch imports+import org.apache.nutch.parse.Parse;import org.apache.nutch.crawl.CrawlDatum;import org.apache.nutch.crawl.Inlinks;-import org.apache.hadoop.io.UTF8;+import org.apache.nutch.plugin.Pluggable;+/** Extension point for indexing. Permits one to add metadata to the indexed* fields. All plugins found which implement this extension point are run* sequentially on the parse.*/-public interface IndexingFilter extends Configurable {+public interface IndexingFilter extends Pluggable, Configurable {/** The name of the extension point. */final static String X_POINT_ID = IndexingFilter.class.getName();diff --git a/src/java/org/apache/nutch/net/URLFilter.java b/src/java/org/apache/nutch/net/URLFilter.javaindex 499a6225a..6b6aaac7a 100644--- a/src/java/org/apache/nutch/net/URLFilter.java+++ b/src/java/org/apache/nutch/net/URLFilter.java@@ -16,14 +16,19 @@package org.apache.nutch.net;+// Hadoop importsimport org.apache.hadoop.conf.Configurable;+// Nutch imports+import org.apache.nutch.plugin.Pluggable;++/*** Interface used to limit which URLs enter Nutch.* Used by the injector and the db updater.*/-public interface URLFilter extends Configurable {+public interface URLFilter extends Pluggable, Configurable {/** The name of the extension point. */public final static String X_POINT_ID = URLFilter.class.getName();diff --git a/src/java/org/apache/nutch/ontology/Ontology.java b/src/java/org/apache/nutch/ontology/Ontology.javaindex 8d8e38baf..3e0a0ffdd 100644--- a/src/java/org/apache/nutch/ontology/Ontology.java+++ b/src/java/org/apache/nutch/ontology/Ontology.java@@ -16,9 +16,14 @@package org.apache.nutch.ontology;+// JDK importsimport java.util.Iterator;-public interface Ontology {+// Nutch imports+import org.apache.nutch.plugin.Pluggable;+++public interface Ontology extends Pluggable {/** The name of the extension point. */public final static String X_POINT_ID = Ontology.class.getName();diff --git a/src/java/org/apache/nutch/parse/HtmlParseFilter.java b/src/java/org/apache/nutch/parse/HtmlParseFilter.javaindex fa3d7321d..34c4b79ba 100644--- a/src/java/org/apache/nutch/parse/HtmlParseFilter.java+++ b/src/java/org/apache/nutch/parse/HtmlParseFilter.java@@ -16,16 +16,22 @@package org.apache.nutch.parse;-import org.apache.nutch.protocol.Content;+// JDK imports+import org.w3c.dom.DocumentFragment;++// Hadoop importsimport org.apache.hadoop.conf.Configurable;-import org.w3c.dom.DocumentFragment;+// Nutch imports+import org.apache.nutch.plugin.Pluggable;+import org.apache.nutch.protocol.Content;+/** Extension point for DOM-based HTML parsers. Permits one to add additional* metadata to HTML parses. All plugins found which implement this extension* point are run sequentially on the parse.*/-public interface HtmlParseFilter extends Configurable {+public interface HtmlParseFilter extends Pluggable, Configurable {/** The name of the extension point. */final static String X_POINT_ID = HtmlParseFilter.class.getName();diff --git a/src/java/org/apache/nutch/parse/Parser.java b/src/java/org/apache/nutch/parse/Parser.javaindex b80fb98f2..2fad84070 100644--- a/src/java/org/apache/nutch/parse/Parser.java+++ b/src/java/org/apache/nutch/parse/Parser.java@@ -16,14 +16,18 @@package org.apache.nutch.parse;-import org.apache.nutch.protocol.Content;+// Hadoop importsimport org.apache.hadoop.conf.Configurable;+// Nutch imports+import org.apache.nutch.plugin.Pluggable;+import org.apache.nutch.protocol.Content;+/** A parser for content generated by a {@link org.apache.nutch.protocol.Protocol}* implementation. This interface is implemented by extensions. Nutch's core* contains no page parsing code.*/-public interface Parser extends Configurable {+public interface Parser extends Pluggable, Configurable {/** The name of the extension point. */public final static String X_POINT_ID = Parser.class.getName();diff --git a/src/java/org/apache/nutch/plugin/Pluggable.java b/src/java/org/apache/nutch/plugin/Pluggable.javanew file mode 100644index 000000000..094468c12--- /dev/null+++ b/src/java/org/apache/nutch/plugin/Pluggable.java@@ -0,0 +1,31 @@+/**+ * Copyright 2005 The Apache Software Foundation+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package org.apache.nutch.plugin;++/**+ * Defines the capability of a class to be plugged into Nutch.+ * This is a common interface that must be implemented by all+ * Nutch Extension Points.+ *+ * @author Jérôme Charron+ *+ * @see <a href="http://wiki.apache.org/nutch/AboutPlugins">About Plugins</a>+ * @see <a href="package-summary.html#package_description">+ * plugin package description</a>+ */+public interface Pluggable {++}diff --git a/src/java/org/apache/nutch/plugin/package.html b/src/java/org/apache/nutch/plugin/package.htmlnew file mode 100644index 000000000..44958852b--- /dev/null+++ b/src/java/org/apache/nutch/plugin/package.html@@ -0,0 +1,38 @@+<html>+<body>+The Nutch {@link org.apache.nutch.plugin.Pluggable Plugin} System.+<p>+<b>The Nutch Plugin System provides a way to extend nutch functionality</b>.+A large part of the functionality of Nutch are provided by plugins:+All of the parsing, indexing and searching that nutch does is actually+accomplished by various plugins.+</p><p>+In writing a plugin, you're actually providing one or more extensions of the+existing extension-points (<i>hooks</i>).+The core Nutch extension-points are themselves defined in a plugin,+the <code>nutch-extensionpoints</code> plugin.+Each extension-point defines an interface that must be implemented by the+extension. The core extension-points and extensions available in Nutch are+listed in the {@link org.apache.nutch.plugin.Pluggable} interface.+</p>++@see <a href="http://wiki.apache.org/nutch/PluginCentral">+ Plugin Central+ </a>+@see <a href="http://wiki.apache.org/nutch/AboutPlugins">+ About Plugins+ </a>+@see <a href="http://wiki.apache.org/nutch/WhyNutchHasAPluginSystem">+ Why Nutch has a Plugin System?+ </a>+@see <a href="http://wiki.apache.org/nutch/WhichTechnicalConceptsAreBehindTheNutchPluginSystem">+ Which technical concepts are behind the nutch plugin system?+ </a>+@see <a href="http://wiki.apache.org/nutch/WhatsTheProblemWithPluginsAndClass-loading">+ What's the problem with Plugins and Class loading?+ </a>+@see <a href="http://wiki.apache.org/nutch/WritingPluginExample">+ Writing Plugin Example+ </a>+</body>+</html>diff --git a/src/java/org/apache/nutch/protocol/Protocol.java b/src/java/org/apache/nutch/protocol/Protocol.javaindex e096df2b1..787d5bade 100755--- a/src/java/org/apache/nutch/protocol/Protocol.java+++ b/src/java/org/apache/nutch/protocol/Protocol.java@@ -16,12 +16,17 @@package org.apache.nutch.protocol;-import org.apache.nutch.crawl.CrawlDatum;-import org.apache.hadoop.io.UTF8;+// Hadoop importsimport org.apache.hadoop.conf.Configurable;+import org.apache.hadoop.io.UTF8;++// Nutch imports+import org.apache.nutch.crawl.CrawlDatum;+import org.apache.nutch.plugin.Pluggable;+/** A retriever of url content. Implemented by protocol extensions. */-public interface Protocol extends Configurable {+public interface Protocol extends Pluggable, Configurable {/** The name of the extension point. */public final static String X_POINT_ID = Protocol.class.getName();diff --git a/src/java/org/apache/nutch/searcher/QueryFilter.java b/src/java/org/apache/nutch/searcher/QueryFilter.javaindex 0c80166a7..e7af65066 100644--- a/src/java/org/apache/nutch/searcher/QueryFilter.java+++ b/src/java/org/apache/nutch/searcher/QueryFilter.java@@ -16,14 +16,21 @@package org.apache.nutch.searcher;+// Lucene importsimport org.apache.lucene.search.BooleanQuery;++// Hadoop importsimport org.apache.hadoop.conf.Configurable;+// Nutch imports+import org.apache.nutch.plugin.Pluggable;++/** Extension point for query translation. Permits one to add metadata to a* query. All plugins found which implement this extension point are run* sequentially on the query.*/-public interface QueryFilter extends Configurable {+public interface QueryFilter extends Pluggable, Configurable {/** The name of the extension point. */final static String X_POINT_ID = QueryFilter.class.getName();