Author: saces
Date: 2007-11-21 13:46:18 +0000 (Wed, 21 Nov 2007)
New Revision: 15902
Modified:
trunk/freenet/src/freenet/node/fcp/FCPPluginMessage.java
trunk/freenet/src/freenet/pluginmanager/FredPluginFCP.java
Log:
use the new fcp plugin code.
Modified: trunk/freenet/src/freenet/node/fcp/FCPPluginMessage.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/FCPPluginMessage.java 2007-11-21
13:45:28 UTC (rev 15901)
+++ trunk/freenet/src/freenet/node/fcp/FCPPluginMessage.java 2007-11-21
13:46:18 UTC (rev 15902)
@@ -4,9 +4,8 @@
package freenet.node.fcp;
import freenet.node.Node;
-import freenet.pluginmanager.FCPPluginOutputWrapper;
-import freenet.pluginmanager.FredPluginFCP;
-import freenet.support.Logger;
+import freenet.pluginmanager.PluginNotFoundException;
+import freenet.pluginmanager.PluginTalker;
import freenet.support.SimpleFieldSet;
import freenet.support.api.Bucket;
@@ -15,7 +14,7 @@
*
* FCPPluginMessage
* Identifer=me
- * PluginName=plugins.HelloFCP (or plugins.HelloFCP.HelloFCP?)
+ * PluginName=plugins.HelloFCP.HelloFCP
* Param.Itemname1=value1
* Param.Itemname2=value2
* ...
@@ -93,28 +92,17 @@
public void run(final FCPConnectionHandler handler, final Node node)
throws MessageInvalidException {
- final Bucket data2 = this.bucket;
- final FCPPluginOutputWrapper replysender = new
FCPPluginOutputWrapper(handler, pluginname, identifier);
- node.executor.execute(new Runnable() {
+ Bucket data2 = this.bucket;
+
+ PluginTalker pt;
+ try {
+ pt = new PluginTalker(node, handler, pluginname,
identifier, handler.hasFullAccess());
+ } catch (PluginNotFoundException e) {
+ throw new
MessageInvalidException(ProtocolErrorMessage.NO_SUCH_PLUGIN, pluginname + " not
found or is not a FCPPlugin", identifier, false);
+ }
+
+ pt.send(plugparams, data2);
- public void run() {
- Logger.normal(this, "Searching fcp plugin: " +
pluginname);
- FredPluginFCP plug =
node.pluginManager.getFCPPlugin(pluginname);
- if (plug == null) {
- Logger.error(this, "Could not find fcp
plugin: " + pluginname);
- return;
- }
- Logger.normal(this, "Found fcp plugin: " +
pluginname);
-
- try {
- plug.handle(replysender, plugparams,
data2, handler.hasFullAccess());
- } catch (Throwable t) {
- Logger.error(this, "Cought error while
execute fcp plugin handler" + t.getMessage(), t);
- }
-
- }
- }, "FCPPlugin runner for " + pluginname);
-
}
}
Modified: trunk/freenet/src/freenet/pluginmanager/FredPluginFCP.java
===================================================================
--- trunk/freenet/src/freenet/pluginmanager/FredPluginFCP.java 2007-11-21
13:45:28 UTC (rev 15901)
+++ trunk/freenet/src/freenet/pluginmanager/FredPluginFCP.java 2007-11-21
13:46:18 UTC (rev 15902)
@@ -7,9 +7,9 @@
import freenet.support.api.Bucket;
/**
- * Interface that has to be implemented for plugins that want to add fcp
commands
- *
- *
+ * Interface that has to be implemented for plugins that want to be talkable
+ * via fcp or direct (plugin to plugin)
+ *
* see plugins.FCPHello for a simple sample.
*
* @author saces
@@ -17,6 +17,12 @@
*/
public interface FredPluginFCP {
- void handle(FCPPluginOutputWrapper replysender, SimpleFieldSet params,
Bucket data, boolean fullacess);
+ /**
+ * @param replysender interface to send a reply
+ * @param params parameters passed in
+ * @param data a bucket of data passed in, can be null
+ * @param access null - direct call (plugin to plugin), if set: FCP
full access
+ */
+ void handle(PluginReplySender replysender, SimpleFieldSet params,
Bucket data, Boolean access);
}