context.setClassShutter(new RestrictiveClassShutter()); context.setOptimizationLevel(9);
/** * Creates a Context object for use with the interpreter. */ protected Context makeContext() { Context cx = super.makeContext(); cx.setWrapFactory(wrapFactory); cx.setSecurityController(securityController); cx.setClassShutter(classShutter); if (rhinoClassLoader == null) { cx.setOptimizationLevel(-1); } return cx; } }
/** * Creates a Context object for use with the interpreter. */ protected Context makeContext() { Context cx = super.makeContext(); cx.setWrapFactory(wrapFactory); cx.setSecurityController(securityController); cx.setClassShutter(classShutter); if (rhinoClassLoader == null) { cx.setOptimizationLevel(-1); } return cx; } }
/** * Creates a Context object for use with the interpreter. */ protected Context makeContext() { Context cx = super.makeContext(); cx.setWrapFactory(wrapFactory); cx.setSecurityController(securityController); cx.setClassShutter(classShutter); if (rhinoClassLoader == null) { cx.setOptimizationLevel(-1); } return cx; } }
public static synchronized void init() throws IOException { if (jsScope != null) return; try { Context jsContext = ContextFactory.getGlobal().enterContext(); jsContext.setClassShutter(new SecurityClassShutter()); jsScope = jsContext.initStandardObjects(null, true); Object o = Context.javaToJS(new TokenApi(), jsScope); ScriptableObject.putProperty(jsScope, "rptools_global_tokens", o); for (String script : JAVASCRIPT_FILES) { Reader reader = new InputStreamReader(ScriptManager.class.getClassLoader().getResourceAsStream(script)); Script compiled = jsContext.compileReader(reader, script, 1, null); compiled.exec(jsContext, jsScope); } // jsScope.sealObject(); } finally { Context.exit(); } }
/** * Create new Context instance to be associated with the current thread. */ @Override protected Context makeContext() { Context cx = super.makeContext(); cx.setLanguageVersion(languageVersion); cx.setOptimizationLevel(optimizationLevel); cx.setClassShutter(RhinoClassShutter.getInstance()); cx.setWrapFactory(RhinoWrapFactory.getInstance()); return cx; }
public static Object evaluate(Map<String, Object> globals, String script) throws IOException { init(); try { Context jsContext = ContextFactory.getGlobal().enterContext(); jsContext.setClassShutter(new SecurityClassShutter()); jsContext.setWrapFactory(new PrimitiveWrapFactory()); Scriptable instanceScope = jsContext.newObject(jsScope); instanceScope.setPrototype(jsScope); instanceScope.setParentScope(null); if (globals != null) { for (Map.Entry<String, Object> entry : globals.entrySet()) { Object wrappedObject = Context.javaToJS(entry.getValue(), instanceScope); ScriptableObject.putProperty(instanceScope, entry.getKey(), wrappedObject); } } Object o = jsContext.evaluateString(instanceScope, script, "evaluate", 1, null); return o; } finally { Context.exit(); } }