public Object eval(String source) throws Exception { Object ret = null; Context cx = Context.enter(); try { cx.putThreadLocal(KEY_SERVICE_CONTEXT, service_context); Scriptable scope = cx.newObject(topLevel); scope.setParentScope(null); scope.setPrototype(topLevel); preDefine(cx, scope); // ScriptImportor.organizeUserImport(cx, scope, service_context); Script scr = CompiledScriptCache.getInstance().getScript(source, cx); ret = scr == null ? null : scr.exec(cx, scope); } catch (RhinoException re) { if (re.getCause() instanceof InterruptException) throw (InterruptException) re.getCause(); throw re; } finally { Context.exit(); } if (ret instanceof Wrapper) { ret = ((Wrapper) ret).unwrap(); } else if (ret instanceof Undefined) ret = null; return ret; }