@Override public Require installRequire(Context cx, List<String> modulePath, boolean sandboxed) { return super.installRequire(cx, modulePath, sandboxed); }
public Object run(Context cx) { if (useRequire) { require = global.installRequire(cx, modulePath, sandboxed); } if (type == PROCESS_FILES) { processFiles(cx, args); } else if (type == EVAL_INLINE_SCRIPT) { evalInlineScript(cx, scriptText); } else { throw Kit.codeBug(); } return null; }
public Object run(Context cx) { if (useRequire) { require = global.installRequire(cx, modulePath, sandboxed); } if (type == PROCESS_FILES) { processFiles(cx, args); } else if (type == EVAL_INLINE_SCRIPT) { evalInlineScript(cx, scriptText); } else { throw Kit.codeBug(); } return null; }
public CommonJSEngineFactory(List<String> modulePaths) { this.modulePaths = modulePaths; Context cx = CommonJSEngine.enterContext(); try { global = new Global(); global.initStandardObjects(cx, true); global.installRequire(cx, modulePaths, true); } finally { Context.exit(); } }
@Override protected Void doCall(Context cx, Scriptable s) { try { Global global = new Global(cx); RequireProperties require = rhinoProperties.getRequire(); if (require != null) { List<String> modulePathURIs = getModulePathURIs(require); LOGGER.debug("Module paths: {}", modulePathURIs); global.installRequire(cx, modulePathURIs, require.isSandboxed()); } // we need to load compat/timeout.js because rhino does not have setTimeout, setInterval, etc. try (Reader in = new InputStreamReader(classloader.getResourceAsStream("compat/timeout.js"))) { cx.evaluateReader(global, in, "compat/timeout.js", 1, null); } scope = global; prototype = new NativeObject(); scope.put("__prototype", scope, prototype); return null; } catch (IOException e) { throw Throwables.propagate(e); } } });