Author: j16sdiz
Date: 2008-12-23 08:08:14 +0000 (Tue, 23 Dec 2008)
New Revision: 24757
Modified:
trunk/plugins/XMLSpider/Config.java
trunk/plugins/XMLSpider/XMLSpider.java
Log:
Config Object: comment, clonable, default value, db4o setting
Modified: trunk/plugins/XMLSpider/Config.java
===================================================================
--- trunk/plugins/XMLSpider/Config.java 2008-12-23 07:01:00 UTC (rev 24756)
+++ trunk/plugins/XMLSpider/Config.java 2008-12-23 08:08:14 UTC (rev 24757)
@@ -4,36 +4,86 @@
package plugins.XMLSpider;
import freenet.node.RequestStarter;
+import freenet.support.Logger;
-class Config {
+class Config implements Cloneable {
/**
- * directory where the generated indices are stored. Needs to be
created before it can be used
+ * Directory where the generated indices are stored
*/
- private String indexDir = "myindex7/";
- private int indexMaxEntries = 2000;
- private long indexSubindexMaxSize = 4 * 1024 * 1024;
+ private String indexDir;
+ private int indexMaxEntries;
+ private long indexSubindexMaxSize;
- private String indexTitle = "XMLSpider index";
- private String indexOwner = "Freenet";
- private String indexOwnerEmail = null;
+ private String indexTitle;
+ private String indexOwner;
+ private String indexOwnerEmail;
- private int maxShownURIs = 15;
+ private int maxShownURIs;
+ private int maxParallelRequests;
+ private String[] badlistedExtensions;
+ private short requestPriority;
- // Can have many; this limit only exists to save memory.
- private int maxParallelRequests = 100;
+ public Config() {
+ } // for db4o
- private String[] badlistedExtensions = new String[] { //
- ".ico", ".bmp", ".png", ".jpg", ".gif", // image
- ".zip", ".jar", ".gz", ".bz2", ".rar", // archive
- ".7z", ".rar", ".arj", ".rpm", ".deb", ".xpi", ".ace", ".cab",
".lza", ".lzh", ".ace", ".exe", ".iso", // binary
- ".mpg", ".ogg", ".mp3", ".avi", // media
- ".css", ".sig" // other
- };
+ public Config(boolean setDefault) {
+ if (!setDefault)
+ return;
- // Equal to Frost, ARK fetches etc. One step down from Fproxy.
- // Any lower makes it very difficult to debug. Maybe reduce for
production - after solving the ARK bugs.
- private short requestPriority =
RequestStarter.IMMEDIATE_SPLITFILE_PRIORITY_CLASS;
+ indexDir = "myindex7/";
+ indexMaxEntries = 2000;
+ indexSubindexMaxSize = 4 * 1024 * 1024;
+ indexTitle = "XMLSpider index";
+ indexOwner = "Freenet";
+ indexOwnerEmail = null;
+
+ maxShownURIs = 15;
+
+ maxParallelRequests = 100;
+
+ badlistedExtensions = new String[] { //
+ ".ico", ".bmp", ".png", ".jpg", ".gif", // image
+ ".zip", ".jar", ".gz", ".bz2", ".rar", // archive
+ ".7z", ".rar", ".arj", ".rpm", ".deb", //
+ ".xpi", ".ace", ".cab", ".lza", ".lzh", //
+ ".ace", ".exe", ".iso", // binary
+ ".mpg", ".ogg", ".mp3", ".avi", // media
+ ".css", ".sig" // other
+ };
+
+ requestPriority =
RequestStarter.IMMEDIATE_SPLITFILE_PRIORITY_CLASS;
+ }
+
+ public synchronized void setValue(Config config) {
+ synchronized (config) {
+ indexDir = config.indexDir;
+ indexMaxEntries = config.indexMaxEntries;
+ indexSubindexMaxSize = config.indexSubindexMaxSize;
+
+ indexTitle = config.indexTitle;
+ indexOwner = config.indexOwner;
+ indexOwnerEmail = config.indexOwnerEmail;
+
+ maxShownURIs = config.maxShownURIs;
+
+ maxParallelRequests = config.maxParallelRequests;
+
+ badlistedExtensions = config.badlistedExtensions;
+
+ requestPriority = config.requestPriority;
+ }
+ }
+
+ public synchronized Config clone() {
+ try {
+ return (Config) super.clone();
+ } catch (CloneNotSupportedException e) {
+ Logger.error(this, "impossible:", e);
+ throw new RuntimeException(e);
+ }
+ }
+
public synchronized void setIndexDir(String indexDir) {
this.indexDir = indexDir;
}
Modified: trunk/plugins/XMLSpider/XMLSpider.java
===================================================================
--- trunk/plugins/XMLSpider/XMLSpider.java 2008-12-23 07:01:00 UTC (rev
24756)
+++ trunk/plugins/XMLSpider/XMLSpider.java 2008-12-23 08:08:14 UTC (rev
24757)
@@ -73,7 +73,7 @@
*
*/
public class XMLSpider implements FredPlugin, FredPluginHTTP,
FredPluginThreadless, FredPluginVersioned, FredPluginL10n, USKCallback {
- private Config config = new Config();
+ private Config config = new Config(true);
public Config getConfig() {
return config;
@@ -926,6 +926,9 @@
cfg.objectClass(TermPosition.class).callConstructor(true);
//- Other
+ cfg.objectClass(MaxPageId.class).callConstructor(true);
+ cfg.objectClass(Config.class).callConstructor(true);
+
cfg.activationDepth(1);
cfg.updateDepth(1);
// cfg.automaticShutDown(false);
_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs