* Add shutdown hooks to ScriptingEngine, RhinoCore and HelmaDebugger.

Fixes bug 586 <http://helma.org/bugs/show_bug.cgi?id=586>
This commit is contained in:
hns 2008-04-02 15:14:30 +00:00
parent 931117a6b6
commit 3e98b9e5c9
6 changed files with 32 additions and 1 deletions

View file

@ -482,8 +482,8 @@ public final class Application implements Runnable {
if (allThreads != null) {
for (Enumeration e = allThreads.elements(); e.hasMoreElements();) {
RequestEvaluator ev = (RequestEvaluator) e.nextElement();
ev.stopTransactor();
ev.shutdown();
}
}

View file

@ -124,6 +124,12 @@ public final class RequestEvaluator implements Runnable {
}
}
protected synchronized void shutdown() {
if (scriptingEngine != null) {
scriptingEngine.shutdown();
}
}
/**
*
*/

View file

@ -60,6 +60,11 @@ public interface ScriptingEngine {
*/
public void init(Application app, RequestEvaluator reval);
/**
* Shut down the Scripting engine.
*/
public void shutdown();
/**
* This method is called when an execution context for a request
* evaluation is entered to let the Engine know it should update

View file

@ -191,6 +191,13 @@ public final class RhinoCore implements ScopeProvider {
return isInitialized;
}
public void shutdown() {
if (debugger != null) {
debugger.dispose();
debugger = null;
}
}
void initDebugger(Context context) {
context.setGeneratingDebug(true);
try {

View file

@ -117,6 +117,13 @@ public class RhinoEngine implements ScriptingEngine {
}
}
/**
* Shut down the scripting engine.
*/
public void shutdown() {
core.shutdown();
}
/**
* Return the RhinoEngine associated with the current thread, or null.
* @return the RhinoEngine assocated with the current thread

View file

@ -113,6 +113,12 @@ public class HelmaDebugger extends Dim implements TreeSelectionListener {
gui.setVisible(visible);
}
public void dispose() {
super.dispose();
gui.setVisible(false);
gui.dispose();
}
class DebuggerTreeNode extends DefaultMutableTreeNode {
public DebuggerTreeNode(Object obj) {