Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

Add support for runtime inter plugin dependencies (using requires section)

Jerome Charronb5126db974ce
diff --git a/src/java/org/apache/nutch/plugin/PluginManifestParser.java b/src/java/org/apache/nutch/plugin/PluginManifestParser.java
index f85dd9d6e..e39f68b98 100644
--- a/src/java/org/apache/nutch/plugin/PluginManifestParser.java
+++ b/src/java/org/apache/nutch/plugin/PluginManifestParser.java
@@ -189,9 +189,35 @@ public class PluginManifestParser {
parseExtension(rootElement, pluginDescriptor);
parseExtensionPoints(rootElement, pluginDescriptor);
parseLibraries(rootElement, pluginDescriptor);
+ parseRequires(rootElement, pluginDescriptor);
return pluginDescriptor;
}
+ /**
+ * @param pRootElement
+ * @param pDescriptor
+ * @throws MalformedURLException
+ */
+ private static void parseRequires(Element pRootElement,
+ PluginDescriptor pDescriptor)
+ throws MalformedURLException {
+
+ NodeList nodelist = pRootElement.getElementsByTagName("requires");
+ if (nodelist.getLength() > 0) {
+
+ Element requires = (Element) nodelist.item(0);
+
+ NodeList imports = requires.getElementsByTagName("import");
+ for (int i=0; i<imports.getLength(); i++) {
+ Element anImport = (Element) imports.item(i);
+ String plugin = anImport.getAttribute("plugin");
+ if (plugin != null) {
+ pDescriptor.addDependency(plugin);
+ }
+ }
+ }
+ }
+
/**
* @param pRootElement
* @param pDescriptor