Hi,

Here's a patch to NutchConf, which gives you a bit more flexibility in the location of the default config files. Currently, if you don't provide the two "magic" files on the classpath (relative to net.nutch.util.NutchConf.class !), sooner or later you will end up with an exception generated because LogFormatter logged a SEVERE message.

This patch enables you to define the default location by setting a system property "nutch.conf.defaultdir".

--
Best regards,
Andrzej Bialecki

-------------------------------------------------
Software Architect, System Integration Specialist
CEN/ISSS EC Workshop, ECIMF project chair
EU FP6 E-Commerce Expert/Evaluator
-------------------------------------------------
FreeBSD developer (http://www.freebsd.org)


Index: NutchConf.java
===================================================================
RCS file: /cvsroot/nutch/nutch/src/java/net/nutch/util/NutchConf.java,v
retrieving revision 1.9
diff -b -d -u -r1.9 NutchConf.java
--- NutchConf.java      5 May 2004 18:23:09 -0000       1.9
+++ NutchConf.java      21 May 2004 11:04:29 -0000
@@ -5,6 +5,7 @@
 
 import java.util.*;
 import java.net.URL;
+import java.io.File;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
@@ -29,8 +30,11 @@
   private static Properties properties;
 
   static {
-    resourceNames.add("nutch-default.xml");
-    resourceNames.add("nutch-site.xml");
+    String defaultDir = System.getProperty("nutch.conf.defaultdir");
+    if (defaultDir == null) defaultDir = "";
+    else defaultDir += File.separator;
+    resourceNames.add(defaultDir + "nutch-default.xml");
+    resourceNames.add(defaultDir + "nutch-site.xml");
   }
 
   /** Adds a resource name to the chain of resources read.  The first resource
@@ -38,7 +42,7 @@
    * <tt>nutch-site.xml</tt>.  New resources are inserted between these, so
    * they can override defaults, but not site-specifics. */
   public static synchronized void addConfResource(String name) {
-    resourceNames.add(resourceNames.size()-1, name); // add second to last
+    resourceNames.add(resourceNames.size() - 1, name); // add second to last
     properties = null;                            // trigger reload
   }
 

Reply via email to