Various minor enhancements and cleanups:

* Implemented rootId property to set the id of the app's root object
* Do not call invokeFunction with a null argument array
* Implement toString() method
* Plus some more minor stuff
This commit is contained in:
hns 2003-11-28 18:27:35 +00:00
parent 874d9fcf97
commit d8b1f178ad

View file

@ -345,8 +345,6 @@ public final class Application implements IPathElement, Runnable {
worker = new Thread(this, "Worker-" + name); worker = new Thread(this, "Worker-" + name);
worker.setPriority(Thread.NORM_PRIORITY + 1); worker.setPriority(Thread.NORM_PRIORITY + 1);
worker.start(); worker.start();
// logEvent ("session cleanup and scheduler thread started");
} }
/** /**
@ -668,10 +666,8 @@ public final class Application implements IPathElement, Runnable {
} }
// no custom root object is defined - use standard helma objectmodel // no custom root object is defined - use standard helma objectmodel
else { else {
// INode root = nmgr.safe.getNode ("0", rootMapping); String rootId = props.getProperty("rootid", "0");
// root.setDbMapping (rootMapping); rootObject = nmgr.safe.getNode(rootId, rootMapping);
// rootObject = root;
rootObject = nmgr.safe.getNode("0", rootMapping);
return rootObject; return rootObject;
} }
@ -1126,13 +1122,17 @@ public final class Application implements IPathElement, Runnable {
private Object invokeFunction(Object obj, String func, Object[] args) { private Object invokeFunction(Object obj, String func, Object[] args) {
RequestEvaluator reval = getCurrentRequestEvaluator(); RequestEvaluator reval = getCurrentRequestEvaluator();
if (args == null) {
args = new Object[0];
}
if (reval != null) { if (reval != null) {
try { try {
return reval.invokeDirectFunction(obj, func, args); return reval.invokeDirectFunction(obj, func, args);
} catch (Exception x) { } catch (Exception x) {
if (debug) { if (debug) {
System.err.println("Error in Application.invokeFunction (" + func + System.err.println("Error in Application.invokeFunction (" +
"): " + x); func + "): " + x);
} }
} }
} }
@ -1163,7 +1163,7 @@ public final class Application implements IPathElement, Runnable {
return ((IPathElement) obj).getElementName(); return ((IPathElement) obj).getElementName();
} }
Object retval = invokeFunction(obj, "getElementName", null); Object retval = invokeFunction(obj, "getElementName", new Object[0]);
if (retval != null) { if (retval != null) {
return retval.toString(); return retval.toString();
@ -1195,7 +1195,7 @@ public final class Application implements IPathElement, Runnable {
return ((IPathElement) obj).getParentElement(); return ((IPathElement) obj).getParentElement();
} }
return invokeFunction(obj, "getParentElement", null); return invokeFunction(obj, "getParentElement", new Object[0]);
} }
/** /**
@ -1263,7 +1263,7 @@ public final class Application implements IPathElement, Runnable {
return "application"; return "application";
} }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/** /**
* Get the logger object for logging generic events * Get the logger object for logging generic events
@ -1465,7 +1465,6 @@ public final class Application implements IPathElement, Runnable {
try { try {
Thread.sleep(sleepInterval); Thread.sleep(sleepInterval);
} catch (InterruptedException x) { } catch (InterruptedException x) {
logEvent("Scheduler for " + name + " interrupted");
worker = null; worker = null;
break; break;
} }
@ -1695,6 +1694,13 @@ public final class Application implements IPathElement, Runnable {
return xmlrpcHandlerName; return xmlrpcHandlerName;
} }
/**
* Return a string representation for this app.
*/
public String toString() {
return "[Application "+name+"]";
}
/** /**
* *
*/ */