Author: cyberdo
Date: 2006-03-04 19:51:04 +0000 (Sat, 04 Mar 2006)
New Revision: 8160
Modified:
trunk/freenet/src/freenet/node/Node.java
trunk/freenet/src/freenet/node/Version.java
trunk/freenet/src/freenet/pluginmanager/PluginManager.java
trunk/freenet/src/freenet/pluginmanager/PluginRespirator.java
Log:
493: Cleaned up the plugin framework to ease usage of the config file
Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java 2006-03-04 18:02:05 UTC (rev
8159)
+++ trunk/freenet/src/freenet/node/Node.java 2006-03-04 19:51:04 UTC (rev
8160)
@@ -852,20 +852,9 @@
putScheduler = new ClientRequestScheduler(true, random,
insertStarter, this);
insertStarter.setScheduler(putScheduler);
insertStarter.start();
+
// And finally, Initialize the plugin manager
- PluginManager pm = null;
- try {
- HighLevelSimpleClient hlsc =
makeClient(RequestStarter.INTERACTIVE_PRIORITY_CLASS);
- /*new HighLevelSimpleClientImpl(this,
- archiveManager, tempBucketFactory,
random, false, (short)0);
- */
- PluginRespirator pluginRespirator = new
PluginRespirator(hlsc);
- pm = new PluginManager(pluginRespirator);
- } catch (Throwable e) {
- e.printStackTrace();
- System.err.println("THIS SHOULDN'T OCCUR!!!! (plugin
system now disabled)");
- }
- pluginManager = pm;
+ pluginManager = new PluginManager(this);
}
private InetAddress resolve(String val) {
Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-03-04 18:02:05 UTC (rev
8159)
+++ trunk/freenet/src/freenet/node/Version.java 2006-03-04 19:51:04 UTC (rev
8160)
@@ -20,7 +20,7 @@
public static final String protocolVersion = "1.0";
/** The build number of the current revision */
- private static final int buildNumber = 492;
+ private static final int buildNumber = 493;
/** Oldest build of Fred we will talk to */
private static final int lastGoodBuild = 475;
Modified: trunk/freenet/src/freenet/pluginmanager/PluginManager.java
===================================================================
--- trunk/freenet/src/freenet/pluginmanager/PluginManager.java 2006-03-04
18:02:05 UTC (rev 8159)
+++ trunk/freenet/src/freenet/pluginmanager/PluginManager.java 2006-03-04
19:51:04 UTC (rev 8160)
@@ -23,10 +23,16 @@
import sun.net.www.protocol.jar.URLJarFile;
import freenet.client.HighLevelSimpleClient;
+import freenet.config.InvalidConfigValueException;
+import freenet.config.StringCallback;
+import freenet.config.SubConfig;
+import freenet.node.Node;
+import freenet.node.RequestStarter;
import freenet.support.Bucket;
import freenet.support.BucketFactory;
import freenet.support.BucketTools;
import freenet.support.Buffer;
+import freenet.support.Logger;
import freenet.support.BucketTools.BucketFactoryWrapper;
public class PluginManager {
@@ -45,23 +51,33 @@
private HashMap pluginInfo;
private PluginManager pluginManager = null;
private PluginRespirator pluginRespirator = null;
+ private Node node;
- public PluginManager(PluginRespirator pluginRespirator) {
+ public PluginManager(Node node) {
pluginInfo = new HashMap();
toadletList = new HashMap();
- this.pluginRespirator = pluginRespirator;
- pluginRespirator.setPluginManager(this);
- //StartPlugin("misc at file:plugin.jar");
+ pluginRespirator = new PluginRespirator(node, this);
- // Needed to include plugin in jar-files
/*
- if (new Date().equals(null)){
- System.err.println(new TestPlugin());
- }
- */
+ SubConfig plugConfig = new SubConfig("pluginmanager",
node.config);
+ // Start plugins in the config
+ plugConfig.register("loadplugin", null, 9, true, "Plugins load
on startup ", "Classpath, name and location for plugins to load when node
starts up",
+ new StringCallback() {
+ public String get() {
+ return storeDir.getPath();
+ }
+ public void set(String val) throws
InvalidConfigValueException {
+ if(storeDir.equals(new
File(val))) return;
+ // FIXME
+ throw new
InvalidConfigValueException("Moving datastore on the fly not supported at
present");
+ }
+ });
+ */
}
+
+
public void startPlugin(String filename) {
FredPlugin plug;
try {
@@ -85,7 +101,7 @@
synchronized (toadletList) {
toadletList.put(pl.getClass().getName(), pl);
}
- System.err.println("Added HTTP handler for
/plugins/"+pl.getClass().getName()+"/");
+ Logger.normal(this, "Added HTTP handler for
/plugins/"+pl.getClass().getName()+"/");
}
public void removePlugin(Thread t) {
@@ -100,7 +116,7 @@
synchronized (toadletList) {
try {
toadletList.remove(pi.getPluginClassName());
-
System.err.println("Removed HTTP handler for /plugins/"+
+ Logger.normal(this,
"Removed HTTP handler for /plugins/"+
pi.getPluginClassName()+"/");
} catch (Throwable ex) {
}
Modified: trunk/freenet/src/freenet/pluginmanager/PluginRespirator.java
===================================================================
--- trunk/freenet/src/freenet/pluginmanager/PluginRespirator.java
2006-03-04 18:02:05 UTC (rev 8159)
+++ trunk/freenet/src/freenet/pluginmanager/PluginRespirator.java
2006-03-04 19:51:04 UTC (rev 8160)
@@ -5,23 +5,21 @@
import freenet.client.HighLevelSimpleClient;
import freenet.client.HighLevelSimpleClientImpl;
import freenet.node.Node;
+import freenet.node.RequestStarter;
public class PluginRespirator {
private HighLevelSimpleClient hlsc = null;
private PluginManager pm = null;
private HashMap toadletList;
+ private Node node;
- public PluginRespirator(HighLevelSimpleClient hlsc) {
- this.hlsc = hlsc;
+ public PluginRespirator(Node node, PluginManager pm) {
+ this.node = node;
+ hlsc =
node.makeClient(RequestStarter.INTERACTIVE_PRIORITY_CLASS);
+ //this.hlsc = hlsc;
toadletList = new HashMap();
}
- public void setPluginManager(PluginManager pm) {
- // Write once only
- if (this.pm == null)
- this.pm = pm;
- }
-
//public HighLevelSimpleClient getHLSimpleClient() throws
PluginSecurityException {
public HighLevelSimpleClient getHLSimpleClient() {
return hlsc;