I was trying to bind a variable but the javascript engine is saying there is no method getRow() on my java object which I do have so I don't get why this code does not work
context.getRow() in the javascript is the issue.
public static void main(String[] args) throws ScriptException, NoSuchMethodException {
Map<String, String> jsonRow = new HashMap<String, String>();
jsonRow.put("temp", "56");
TriggerContext ctx = new TriggerContext(jsonRow , null);
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("javascript");
engine.put("context", ctx);
//Object result = compiledScript.eval();
engine.eval("function trigger() { var t = context.getRow(); var val = t['temp']; if(val > 55) return false; else return true; }");
Invocable inv = (Invocable) engine;
// invoke the global function named "hello"
Object result = inv.invokeFunction("trigger" );
System.out.println("result="+result);
System.out.println("type="+result.getClass());
}