Actually I try to pass a JavaScript script function to work as callback for script in a Java method I am doing
I can do this - like - but the object I get is a sun.org.mozilla.javascript.internal.InterpretedFunction and I do not see a way to implement it.
Any thoughts?
Even what I have so far:
var someNumber = 0; Start the function () {// log is just a log4j example that has been added to binding log.info ("starting ...."); Some numbers = 20; // Test is a unit test object with this method (taking the object as the ultimate) test.callFromRhino (junk); } Function junk () {log.info ("recalled" + some numbers); }
Apply an interface:
import Javax .script *. Public class callback {public zero start (runnable runner) {runnable.run (); } Public static zero chief (string [] Args throws ScriptException {ScriptEngine js = new scriptEngineManager (). GetEngineByExtension ("js"); Js.getContext (). SetAttribute ("callback", new callback (), ScriptContext.ENGINE_SCOPE); Js.eval ("var impl = {run: function ()} {print ('hello, world!');}}; \ N" + "var runable = new java.range.runable (vested); \ n" + "CallBack.invoke (runnable); \ n"); }}
Comments
Post a Comment