Author: xor Date: 2009-03-19 06:44:55 +0000 (Thu, 19 Mar 2009) New Revision: 26103
Removed: trunk/freenet/src/freenet/pluginmanager/PluginReplySenderBlocking.java Modified: trunk/freenet/src/freenet/pluginmanager/PluginTalker.java Log: Remove the blocking code from PluginTalker and implement it in the plugin itself as suggested by saces and sdiz. Deleted: trunk/freenet/src/freenet/pluginmanager/PluginReplySenderBlocking.java =================================================================== --- trunk/freenet/src/freenet/pluginmanager/PluginReplySenderBlocking.java 2009-03-18 19:35:03 UTC (rev 26102) +++ trunk/freenet/src/freenet/pluginmanager/PluginReplySenderBlocking.java 2009-03-19 06:44:55 UTC (rev 26103) @@ -1,45 +0,0 @@ -/* This code is part of Freenet. It is distributed under the GNU General - * Public License, version 2 (or at your option any later version). See - * http://www.gnu.org/ for further details of the GPL. */ -package freenet.pluginmanager; - -import freenet.pluginmanager.PluginTalker.Result; -import freenet.support.Logger; -import freenet.support.SimpleFieldSet; -import freenet.support.api.Bucket; - -/** - * - * @author xor - * - */ -public class PluginReplySenderBlocking extends PluginReplySender { - - protected volatile PluginTalker.Result mResult; - - public PluginReplySenderBlocking(String myPluginName, String myConnectionIdentifier) { - super(myPluginName, myConnectionIdentifier); - } - - @Override - public synchronized void send(SimpleFieldSet params, Bucket bucket) { - if(mResult == null) { - mResult = new Result(params, bucket); - notifyAll(); - } else { - Logger.error(this, "PluginTalker.sendBlocking() is being used with a FCP call which results in more than 1 reply"); - } - } - - public Result getResult() { - while(mResult == null) { - try { - wait(); - } catch (InterruptedException e) { - } - } - - return mResult; - } - -} \ No newline at end of file Modified: trunk/freenet/src/freenet/pluginmanager/PluginTalker.java =================================================================== --- trunk/freenet/src/freenet/pluginmanager/PluginTalker.java 2009-03-18 19:35:03 UTC (rev 26102) +++ trunk/freenet/src/freenet/pluginmanager/PluginTalker.java 2009-03-19 06:44:55 UTC (rev 26103) @@ -22,24 +22,21 @@ protected FredPluginFCP plugin; protected String pluginName; - protected String connectionIdentifier; - public PluginTalker(FredPluginTalker fpt, Node node2, String pluginname2, String identifier2) throws PluginNotFoundException { + public PluginTalker(FredPluginTalker fpt, Node node2, String pluginname2, String connectionIdentifier) throws PluginNotFoundException { node = node2; pluginName = pluginname2; - connectionIdentifier = identifier2; plugin = findPlugin(pluginname2); access = FredPluginFCP.ACCESS_DIRECT; - replysender = new PluginReplySenderDirect(node2, fpt, pluginname2, identifier2); + replysender = new PluginReplySenderDirect(node2, fpt, pluginname2, connectionIdentifier); } - public PluginTalker(Node node2, FCPConnectionHandler handler, String pluginname2, String identifier2, boolean access2) throws PluginNotFoundException { + public PluginTalker(Node node2, FCPConnectionHandler handler, String pluginname2, String connectionIdentifier, boolean access2) throws PluginNotFoundException { node = node2; pluginName = pluginname2; - connectionIdentifier = identifier2; plugin = findPlugin(pluginname2); access = access2 ? FredPluginFCP.ACCESS_FCP_FULL : FredPluginFCP.ACCESS_FCP_RESTRICTED; - replysender = new PluginReplySenderFCP(handler, pluginname2, identifier2); + replysender = new PluginReplySenderFCP(handler, pluginname2, connectionIdentifier); } protected FredPluginFCP findPlugin(String pluginname2) throws PluginNotFoundException { @@ -67,34 +64,4 @@ } - public static class Result { - public SimpleFieldSet params; - public Bucket data; - - public Result(SimpleFieldSet myParams, Bucket myData) { - params = myParams; - data = myData; - } - } - - /** - * Sends a FCP message and blocks execution until the answer was received and then returns the answer. - * This can be used to simplify code which uses FCP very much, especially UI code which needs the result of FCP calls directly. - * - * When using sendBlocking(), please make sure that you only ever call it for FCP functions which only send() a single result! - * Results which are sent by the plugin after the first result are dispatched to the asynchronous onReply() function of your - * FredPluginTalker, however this behavior is deprecated and not guranteed to work. - */ - public Result sendBlocking(final SimpleFieldSet plugparams, final Bucket data2) { - final PluginReplySenderBlocking replySender = new PluginReplySenderBlocking(pluginName, connectionIdentifier); - - node.executor.execute(new Runnable() { - - public void run() { - plugin.handle(replySender, plugparams, data2, access); - } - }, "PluginTalkerBlocking " + connectionIdentifier); - - return replySender.getResult(); - } } _______________________________________________ cvs mailing list [email protected] http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
