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

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

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

Context.seal介绍

[英]Seal this Context object so any attempt to modify any of its properties including calling #enter() and #exit() methods will throw an exception.

If sealKey is not null, calling #unseal(Object sealKey) with the same key unseals the object. If sealKey is null, unsealing is no longer possible.
[中]密封此上下文对象,以便任何修改其任何属性(包括调用#enter()和#exit()方法)的尝试都会引发异常。
如果sealKey不为null,则使用相同的键调用#uncel(Object sealKey)将解封对象。如果sealKey为null,则无法再解封。

代码示例

代码示例来源:origin: com.sun.phobos/phobos-rhino

private static Context prepareNewContext(ContextFactory factory,
                     Object contextHelper)
{
  Context cx = factory.makeContext();
  if (cx.factory != null || cx.enterCount != 0) {
    throw new IllegalStateException("factory.makeContext() returned Context instance already associated with some thread");
  }
  cx.factory = factory;
  factory.onContextCreated(cx);
  if (factory.isSealed() && !cx.isSealed()) {
    cx.seal(null);
  }
  VMBridge.instance.setContext(contextHelper, cx);
  return cx;
}

代码示例来源:origin: geogebra/geogebra

static final Context enter(Context cx, ContextFactory factory)
{
  Object helper = VMBridge.instance.getThreadContextHelper();
  Context old = VMBridge.instance.getContext(helper);
  if (old != null) {
    cx = old;
  } else {
    if (cx == null) {
      cx = factory.makeContext();
      if (cx.enterCount != 0) {
        throw new IllegalStateException("factory.makeContext() returned Context instance already associated with some thread");
      }
      factory.onContextCreated(cx);
      if (factory.isSealed() && !cx.isSealed()) {
        cx.seal(null);
      }
    } else {
      if (cx.enterCount != 0) {
        throw new IllegalStateException("can not use Context instance already associated with some thread");
      }
    }
    VMBridge.instance.setContext(helper, cx);
  }
  ++cx.enterCount;
  return cx;
 }

代码示例来源:origin: rhino/js

static final Context enter(Context cx, ContextFactory factory)
{
  Object helper = VMBridge.instance.getThreadContextHelper();
  Context old = VMBridge.instance.getContext(helper);
  if (old != null) {
    cx = old;
  } else {
    if (cx == null) {
      cx = factory.makeContext();
      if (cx.enterCount != 0) {
        throw new IllegalStateException("factory.makeContext() returned Context instance already associated with some thread");
      }
      factory.onContextCreated(cx);
      if (factory.isSealed() && !cx.isSealed()) {
        cx.seal(null);
      }
    } else {
      if (cx.enterCount != 0) {
        throw new IllegalStateException("can not use Context instance already associated with some thread");
      }
    }
    VMBridge.instance.setContext(helper, cx);
  }
  ++cx.enterCount;
  return cx;
 }

代码示例来源:origin: ro.isdc.wro4j/rhino

static final Context enter(Context cx, ContextFactory factory)
{
  Object helper = VMBridge.instance.getThreadContextHelper();
  Context old = VMBridge.instance.getContext(helper);
  if (old != null) {
    cx = old;
  } else {
    if (cx == null) {
      cx = factory.makeContext();
      if (cx.enterCount != 0) {
        throw new IllegalStateException("factory.makeContext() returned Context instance already associated with some thread");
      }
      factory.onContextCreated(cx);
      if (factory.isSealed() && !cx.isSealed()) {
        cx.seal(null);
      }
    } else {
      if (cx.enterCount != 0) {
        throw new IllegalStateException("can not use Context instance already associated with some thread");
      }
    }
    VMBridge.instance.setContext(helper, cx);
  }
  ++cx.enterCount;
  return cx;
 }

代码示例来源:origin: com.github.tntim96/rhino

static final Context enter(Context cx, ContextFactory factory)
{
  Object helper = VMBridge.instance.getThreadContextHelper();
  Context old = VMBridge.instance.getContext(helper);
  if (old != null) {
    cx = old;
  } else {
    if (cx == null) {
      cx = factory.makeContext();
      if (cx.enterCount != 0) {
        throw new IllegalStateException("factory.makeContext() returned Context instance already associated with some thread");
      }
      factory.onContextCreated(cx);
      if (factory.isSealed() && !cx.isSealed()) {
        cx.seal(null);
      }
    } else {
      if (cx.enterCount != 0) {
        throw new IllegalStateException("can not use Context instance already associated with some thread");
      }
    }
    VMBridge.instance.setContext(helper, cx);
  }
  ++cx.enterCount;
  return cx;
 }

代码示例来源:origin: io.apigee/rhino

static final Context enter(Context cx, ContextFactory factory)
{
  Object helper = VMBridge.instance.getThreadContextHelper();
  Context old = VMBridge.instance.getContext(helper);
  if (old != null) {
    cx = old;
  } else {
    if (cx == null) {
      cx = factory.makeContext();
      if (cx.enterCount != 0) {
        throw new IllegalStateException("factory.makeContext() returned Context instance already associated with some thread");
      }
      factory.onContextCreated(cx);
      if (factory.isSealed() && !cx.isSealed()) {
        cx.seal(null);
      }
    } else {
      if (cx.enterCount != 0) {
        throw new IllegalStateException("can not use Context instance already associated with some thread");
      }
    }
    VMBridge.instance.setContext(helper, cx);
  }
  ++cx.enterCount;
  return cx;
 }

相关文章

微信公众号

Context类方法