public class SafeSleep implements Runnable
{
protected Scalar result = null;
protected ScriptInstance scriptLoader;
public Scalar callSleepScript(long timeout)
{
> ScriptLoader loader = new ScriptLoader();
>
> loader.addSpecificBridge(new MyLoadableBridge());
> StringBuffer jarPath = new StringBuffer(<sleep_jar_path>);
>
> ParserConfig.setSleepClasspath(jarPath.toString());
>
> String sleepScript = <sleep_script_path>;
> scriptLoad = loader.loadScript();
Thread fred = new Thread(this);
fred.run();
fred.join(timeout);
// this may not be necessary so comment it out if it isn't...
and if a timeout occurs you'll need to reload the script
// this line forces the script to exit... this is how &exit()
tells the interpreter to exit FYI
scriptLoad.getScriptEnvironment().flagReturn(null,
ScriptEnvironment.FLOW_CONTROL_THROW);
return result;
> }
public void run()
{
> scriptLoad.runScript();
> result = scriptLoad.callFunction("&"+"func_name", stack);
}
}
Now when you want to call a SafeSleep with a timeout you can do new
SafeSleep().callSleepScript(10000);
I haven't tested this code but I assume the skeleton of it should
suit your purposes.
Good luck.
-- Raphael
P.S. you're not flagged to receive email from the mailing list so I
BCC'd you this reply.
-Andreas
At least there is a work around :)
-- Raphael
P.S. now that all the memory issues are under control, any interest
in another release of the Moconti Web App server? Its hosting
www.polishmywriting.com, jircii.dashnine.org, and
sleep.dashnine.org. Its been running for a few weeks with no problems.