Author: toad
Date: 2008-02-12 14:02:29 +0000 (Tue, 12 Feb 2008)
New Revision: 17818
Modified:
trunk/freenet/src/freenet/clients/http/FProxyToadlet.java
trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
trunk/freenet/src/freenet/node/NodeClientCore.java
Log:
Lazy init: create the fproxy structures on fproxy being enabled or on startup.
Modified: trunk/freenet/src/freenet/clients/http/FProxyToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/FProxyToadlet.java 2008-02-12
13:57:19 UTC (rev 17817)
+++ trunk/freenet/src/freenet/clients/http/FProxyToadlet.java 2008-02-12
14:02:29 UTC (rev 17818)
@@ -595,7 +595,7 @@
return f;
}
- public static void maybeCreateFProxyEtc(NodeClientCore core, Node node,
Config config, SimpleToadletServer server) throws IOException,
InvalidConfigValueException {
+ public static void maybeCreateFProxyEtc(NodeClientCore core, Node node,
Config config, SimpleToadletServer server) throws IOException {
// FIXME how to change these on the fly when the interface
language is changed?
Modified: trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
2008-02-12 13:57:19 UTC (rev 17817)
+++ trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
2008-02-12 14:02:29 UTC (rev 17818)
@@ -199,11 +199,28 @@
return;
}
}
+ createFproxy();
myThread.setDaemon(true);
myThread.start();
}
}
+ private boolean haveCalledFProxy = false;
+
+ public void createFproxy() {
+ synchronized(this) {
+ if(haveCalledFProxy) return;
+ haveCalledFProxy = true;
+ }
+ try {
+ FProxyToadlet.maybeCreateFProxyEtc(core, core.node,
core.node.config, SimpleToadletServer.this);
+ } catch (IOException e) {
+ Logger.error(this, "Could not start fproxy: "+e, e);
+ System.err.println("Could not start fproxy:");
+ e.printStackTrace();
+ }
+ }
+
private static class FProxyAdvancedModeEnabledCallback implements
BooleanCallback {
private final SimpleToadletServer ts;
Modified: trunk/freenet/src/freenet/node/NodeClientCore.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeClientCore.java 2008-02-12 13:57:19 UTC
(rev 17817)
+++ trunk/freenet/src/freenet/node/NodeClientCore.java 2008-02-12 14:02:29 UTC
(rev 17818)
@@ -83,7 +83,7 @@
private boolean uploadAllowedEverywhere;
final FilenameGenerator tempFilenameGenerator;
public final BucketFactory tempBucketFactory;
- final Node node;
+ public final Node node;
final NodeStats nodeStats;
public final RandomSource random;
final File tempDir;
@@ -355,18 +355,11 @@
// FProxy
// FIXME this is a hack, the real way to do this is plugins
this.alerts.register(startingUpAlert = new
SimpleUserAlert(true, l10n("startingUpTitle"), l10n("startingUp"),
UserAlert.MINOR));
- try {
toadletContainer = toadlets;
toadletContainer.setCore(this);
toadletContainer.setBucketFactory(tempBucketFactory);
- FProxyToadlet.maybeCreateFProxyEtc(this, node, config,
toadletContainer);
+ toadletContainer.createFproxy();
toadletContainer.removeStartupToadlet();
- } catch (IOException e) {
- e.printStackTrace();
- throw new
NodeInitException(NodeInitException.EXIT_COULD_NOT_START_FPROXY, "Could not
start FProxy: "+e);
- } catch (InvalidConfigValueException e) {
- throw new
NodeInitException(NodeInitException.EXIT_COULD_NOT_START_FPROXY, "Could not
start FProxy: "+e);
- }
}