org.mozilla.javascript.Context.setClassShutter()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 JavaScript  
字(3.4k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中org.mozilla.javascript.Context.setClassShutter()方法的一些代码示例,展示了Context.setClassShutter()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.setClassShutter()方法的具体详情如下:
包路径:org.mozilla.javascript.Context
类名称:Context
方法名:setClassShutter

Context.setClassShutter介绍

[英]Set the LiveConnect access filter for this context.

ClassShutter may only be set if it is currently null. Otherwise a SecurityException is thrown.
[中]为此上下文设置LiveConnect访问筛选器。
ClassShutter只能在当前为空时设置。否则将引发SecurityException。

代码示例

代码示例来源:origin: rnewson/couchdb-lucene

context.setClassShutter(new RestrictiveClassShutter());
context.setOptimizationLevel(9);

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

/**
   * 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;
  }
}

代码示例来源:origin: apache/batik

/**
   * 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;
  }
}

代码示例来源:origin: org.apache.xmlgraphics/batik-bridge

/**
   * 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;
  }
}

代码示例来源:origin: RPTools/maptool

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();
  }
}

代码示例来源:origin: io.apisense/rhino-android

/**
 * 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;
}

代码示例来源:origin: RPTools/maptool

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();
  }
}

相关文章

微信公众号

Context类方法