Author: nextgens
Date: 2007-11-19 14:20:43 +0000 (Mon, 19 Nov 2007)
New Revision: 15826

Modified:
   trunk/freenet/src/freenet/clients/http/StartupToadletServer.java
   trunk/freenet/src/freenet/config/PersistentConfig.java
   trunk/freenet/src/freenet/node/Node.java
Log:
StartupToadlet: read the config. file only once

Modified: trunk/freenet/src/freenet/clients/http/StartupToadletServer.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/StartupToadletServer.java    
2007-11-19 14:04:24 UTC (rev 15825)
+++ trunk/freenet/src/freenet/clients/http/StartupToadletServer.java    
2007-11-19 14:20:43 UTC (rev 15826)
@@ -3,6 +3,7 @@
  * http://www.gnu.org/ for further details of the GPL. */
 package freenet.clients.http;

+import freenet.config.PersistentConfig;
 import freenet.support.HTMLNode;
 import java.io.File;
 import java.io.IOException;
@@ -51,7 +52,6 @@
     private String formPassword;
     private Executor executor;
     private final BucketFactory bf = new ArrayBucketFactory();
-    private final File configFile = new File("freenet.ini");
     private final ToadletContainer container = new ToadletContainer() {

         public void register(Toadlet t, String urlPrefix, boolean atFront, 
boolean fullAccessOnly) {
@@ -124,14 +124,14 @@
         * Create a SimpleToadletServer, using the settings from the SubConfig 
(the fproxy.*
         * config).
         */
-    public StartupToadletServer(Executor executor) {
+    public StartupToadletServer(Executor executor, PersistentConfig conf) {
         int configItemOrder = 0;
         this.executor = executor;
         formPassword = String.valueOf(this.getClass().hashCode());

         // hack ... we don't have the config framework yet
         try {
-            SimpleFieldSet config = SimpleFieldSet.readFrom(configFile, false, 
false);
+            SimpleFieldSet config = conf.getSimpleFieldSet();
             port = config.getInt("fproxy.port");
             bindTo = config.get("fproxy.bindTo");
             // Yeah, only FullAccess hosts here, it's on purpose.

Modified: trunk/freenet/src/freenet/config/PersistentConfig.java
===================================================================
--- trunk/freenet/src/freenet/config/PersistentConfig.java      2007-11-19 
14:04:24 UTC (rev 15825)
+++ trunk/freenet/src/freenet/config/PersistentConfig.java      2007-11-19 
14:20:43 UTC (rev 15826)
@@ -72,5 +72,13 @@
                        Logger.error(this, "Could not parse config option 
"+name+": "+e, e);
                }
        }
-
+        
+        /**
+         * Return a copy of the SFS as read by the config framework.
+         * 
+         * @return a SFS or null if initialization is finished.
+         */
+        public synchronized SimpleFieldSet getSimpleFieldSet() {
+            return (origConfigFileContents == null ? null : new 
SimpleFieldSet(origConfigFileContents));
+        }
 }

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2007-11-19 14:04:24 UTC (rev 
15825)
+++ trunk/freenet/src/freenet/node/Node.java    2007-11-19 14:20:43 UTC (rev 
15826)
@@ -546,7 +546,7 @@
                startupTime = System.currentTimeMillis();
                 // Will be set up properly afterwards
                 L10n.setLanguage(L10n.FALLBACK_DEFAULT);
-                startupPageHolder = new StartupToadletServer(executor);
+                startupPageHolder = new StartupToadletServer(executor, config);
                nodeNameUserAlert = new MeaningfulNodeNameUserAlert(this);
                recentlyCompletedIDs = new LRUQueue();
                this.config = config;


Reply via email to