Most properties in app.properties are now updatable during runtime.
This commit is contained in:
parent
2dda7607c5
commit
369a36534a
2 changed files with 51 additions and 28 deletions
|
@ -118,6 +118,8 @@ public final class Application
|
||||||
// DocApplication used for introspection
|
// DocApplication used for introspection
|
||||||
public DocApplication docApp;
|
public DocApplication docApp;
|
||||||
|
|
||||||
|
private long lastPropertyRead = 0l;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Zero argument constructor needed for RMI
|
* 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.
|
// get class name of root object if defined. Otherwise native Helma objectmodel will be used.
|
||||||
rootObjectClass = classMapping.getProperty ("root");
|
rootObjectClass = classMapping.getProperty ("root");
|
||||||
|
|
||||||
// character encoding to be used for responses
|
updateProperties ();
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
sessions = new Hashtable ();
|
sessions = new Hashtable ();
|
||||||
dbSources = new Hashtable ();
|
dbSources = new Hashtable ();
|
||||||
|
@ -256,15 +247,17 @@ public final class Application
|
||||||
freeThreads = new Stack ();
|
freeThreads = new Stack ();
|
||||||
allThreads = new Vector ();
|
allThreads = new Vector ();
|
||||||
// allThreads.addElement (eval);
|
// allThreads.addElement (eval);
|
||||||
/* int maxThreads = 12;
|
|
||||||
|
// preallocate minThreads request evaluators
|
||||||
|
int minThreads = 0;
|
||||||
try {
|
try {
|
||||||
maxThreads = Integer.parseInt (props.getProperty ("maxThreads"));
|
minThreads = Integer.parseInt (props.getProperty ("minThreads"));
|
||||||
} catch (Exception ignore) {}
|
} catch (Exception ignore) {}
|
||||||
for (int i=0; i<maxThreads; i++) {
|
for (int i=0; i<minThreads; i++) {
|
||||||
RequestEvaluator ev = new RequestEvaluator (this);
|
RequestEvaluator ev = new RequestEvaluator (this);
|
||||||
freeThreads.push (ev);
|
freeThreads.push (ev);
|
||||||
allThreads.addElement (ev);
|
allThreads.addElement (ev);
|
||||||
} */
|
}
|
||||||
activeRequests = new Hashtable ();
|
activeRequests = new Hashtable ();
|
||||||
|
|
||||||
skinmgr = new SkinManager (this);
|
skinmgr = new SkinManager (this);
|
||||||
|
@ -275,7 +268,6 @@ public final class Application
|
||||||
String usernameField = userMapping.getNameField ();
|
String usernameField = userMapping.getNameField ();
|
||||||
if (usernameField == null)
|
if (usernameField == null)
|
||||||
usernameField = "name";
|
usernameField = "name";
|
||||||
p.put ("_version","1.2");
|
|
||||||
p.put ("_children", "collection(user)");
|
p.put ("_children", "collection(user)");
|
||||||
p.put ("_children.accessname", usernameField);
|
p.put ("_children.accessname", usernameField);
|
||||||
userRootMapping = new DbMapping (this, "__userroot__", p);
|
userRootMapping = new DbMapping (this, "__userroot__", p);
|
||||||
|
@ -458,6 +450,10 @@ public final class Application
|
||||||
primaryRequest = true;
|
primaryRequest = true;
|
||||||
// if attachRequest returns null this means we came too late
|
// if attachRequest returns null this means we came too late
|
||||||
// and the other request was finished in the meantime
|
// and the other request was finished in the meantime
|
||||||
|
|
||||||
|
// check if the properties file has been updated
|
||||||
|
updateProperties ();
|
||||||
|
// get evaluator and invoke
|
||||||
ev = getEvaluator ();
|
ev = getEvaluator ();
|
||||||
res = ev.invoke (req, session);
|
res = ev.invoke (req, session);
|
||||||
}
|
}
|
||||||
|
@ -830,19 +826,11 @@ public final class Application
|
||||||
* Return a path to be used in a URL pointing to the given element and action
|
* Return a path to be used in a URL pointing to the given element and action
|
||||||
*/
|
*/
|
||||||
public String getNodeHref (Object elem, String actionName) {
|
public String getNodeHref (Object elem, String actionName) {
|
||||||
// FIXME: will fail for non-node roots
|
|
||||||
Object root = getDataRoot ();
|
Object root = getDataRoot ();
|
||||||
INode users = getUserRoot ();
|
|
||||||
|
|
||||||
// check base uri and optional root prototype from app.properties
|
// check optional root prototype from app.properties
|
||||||
String base = props.getProperty ("baseURI");
|
|
||||||
String rootproto = props.getProperty ("rootPrototype");
|
String rootproto = props.getProperty ("rootPrototype");
|
||||||
|
|
||||||
if (base != null || baseURI == null)
|
|
||||||
setBaseURI (base);
|
|
||||||
|
|
||||||
// String href = n.getUrl (root, users, tmpname, siteroot);
|
|
||||||
|
|
||||||
String divider = "/";
|
String divider = "/";
|
||||||
StringBuffer b = new StringBuffer ();
|
StringBuffer b = new StringBuffer ();
|
||||||
Object p = elem;
|
Object p = elem;
|
||||||
|
@ -1201,6 +1189,32 @@ public final class Application
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private synchronized void updateProperties () {
|
||||||
|
// if so property file has been updated, re-read props.
|
||||||
|
if (props.lastModified () > 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.
|
* Proxy method to get a property from the applications properties.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -73,6 +73,15 @@ public final class NodeManager {
|
||||||
logSql = "true".equalsIgnoreCase(props.getProperty ("logsql"));
|
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.
|
* Method used to create the root node and id-generator, if they don't exist already.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue