From 369a36534ab39f2a0dc212bd686966b2b152d47f Mon Sep 17 00:00:00 2001 From: hns Date: Tue, 17 Sep 2002 22:44:03 +0000 Subject: [PATCH] Most properties in app.properties are now updatable during runtime. --- src/helma/framework/core/Application.java | 70 ++++++++++++++--------- src/helma/objectmodel/db/NodeManager.java | 9 +++ 2 files changed, 51 insertions(+), 28 deletions(-) diff --git a/src/helma/framework/core/Application.java b/src/helma/framework/core/Application.java index f61bf1c3..f096a8bd 100644 --- a/src/helma/framework/core/Application.java +++ b/src/helma/framework/core/Application.java @@ -117,6 +117,8 @@ public final class Application // DocApplication used for introspection public DocApplication docApp; + + private long lastPropertyRead = 0l; /** * Zero argument constructor needed for RMI @@ -209,18 +211,7 @@ public final class Application // get class name of root object if defined. Otherwise native Helma objectmodel will be used. rootObjectClass = classMapping.getProperty ("root"); - // character encoding to be used for responses - charset = props.getProperty ("charset", "ISO-8859-1"); - - debug = "true".equalsIgnoreCase (props.getProperty ("debug")); - // checkSubnodes = !"false".equalsIgnoreCase (props.getProperty ("subnodeChecking")); - - - try { - requestTimeout = Long.parseLong (props.getProperty ("requestTimeout", "60"))*1000l; - } catch (Exception ignore) { - // go with default value - } + updateProperties (); sessions = new Hashtable (); dbSources = new Hashtable (); @@ -256,15 +247,17 @@ public final class Application freeThreads = new Stack (); allThreads = new Vector (); // allThreads.addElement (eval); - /* int maxThreads = 12; + + // preallocate minThreads request evaluators + int minThreads = 0; try { - maxThreads = Integer.parseInt (props.getProperty ("maxThreads")); + minThreads = Integer.parseInt (props.getProperty ("minThreads")); } catch (Exception ignore) {} - for (int i=0; i lastPropertyRead) { + // character encoding to be used for responses + charset = props.getProperty ("charset", "ISO-8859-1"); + // debug flag + debug = "true".equalsIgnoreCase (props.getProperty ("debug")); + try { + requestTimeout = Long.parseLong (props.getProperty ("requestTimeout", "60"))*1000l; + } catch (Exception ignore) { + // go with default value + requestTimeout = 60000l; + } + // set base URI + String base = props.getProperty ("baseURI"); + if (base != null) + setBaseURI (base); + // if node manager exists, update it + if (nmgr != null) + nmgr.updateProperties (props); + // set prop read timestamp + lastPropertyRead = props.lastModified (); + } + } + + /** * Proxy method to get a property from the applications properties. */ @@ -1359,8 +1373,8 @@ class XmlRpcAccess { throw new Exception ("Method "+method+" is not callable via XML-RPC"); } - /* - * create internal representation of XML-RPC-Permissions. They're encoded in the app property + /* + * create internal representation of XML-RPC-Permissions. They're encoded in the app property * file like this: * * xmlrpcAccess = root.sayHello, story.countMessages, user.login diff --git a/src/helma/objectmodel/db/NodeManager.java b/src/helma/objectmodel/db/NodeManager.java index 24e87bbc..c15a70c6 100644 --- a/src/helma/objectmodel/db/NodeManager.java +++ b/src/helma/objectmodel/db/NodeManager.java @@ -73,6 +73,15 @@ public final class NodeManager { logSql = "true".equalsIgnoreCase(props.getProperty ("logsql")); } + /** + * app.properties file has been updated. Reread some settings. + */ + public void updateProperties (Properties props) { + int cacheSize = Integer.parseInt (props.getProperty ("cachesize", "1000")); + cache.setCapacity (cacheSize); + logSql = "true".equalsIgnoreCase(props.getProperty ("logsql")); + } + /** * Method used to create the root node and id-generator, if they don't exist already. */