List of usage examples for javax.script SimpleBindings get
public Object get(Object key)
From source file:org.nuxeo.ecm.webengine.scripting.Scripting.java
protected Object _runScript(ScriptFile script, Map<String, Object> args) throws Exception { SimpleBindings bindings = new SimpleBindings(); if (args != null) { bindings.putAll(args);//w w w . ja v a2 s . c o m } String ext = script.getExtension(); // check for a script engine ScriptEngine engine = getEngineManager().getEngineByExtension(ext); if (engine != null) { ScriptContext ctx = new SimpleScriptContext(); ctx.setBindings(bindings, ScriptContext.ENGINE_SCOPE); CompiledScript comp = getCompiledScript(engine, script.getFile()); // use cache for compiled scripts if (comp != null) { return comp.eval(ctx); } // compilation not supported - eval it on the fly try { Reader reader = new FileReader(script.getFile()); try { // TODO use __result__ to pass return value for engine that doesn't returns like jython Object result = engine.eval(reader, ctx); if (result == null) { result = bindings.get("__result__"); } return result; } finally { reader.close(); } } catch (IOException e) { throw new ScriptException(e); } } return null; }