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

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

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

Context.getFactory介绍

[英]Return ContextFactory instance used to create this Context.
[中]返回用于创建此上下文的ContextFactory实例。

代码示例

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

/**
 * Create class loader for generated classes.
 * The method calls {@link ContextFactory#createClassLoader(ClassLoader)}
 * using the result of {@link #getFactory()}.
 */
public GeneratedClassLoader createClassLoader(ClassLoader parent)
{
  ContextFactory f = getFactory();
  return f.createClassLoader(parent);
}

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

/**
  Returns an object which specifies an E4X implementation to use within
  this <code>Context</code>.  Note
  that the XMLLib.Factory interface should be considered experimental.
 
  The default implementation uses the implementation provided by this
  <code>Context</code>'s {@link ContextFactory}.
 
  @return An XMLLib.Factory.  Should not return <code>null</code> if
    {@link #FEATURE_E4X} is enabled.  See {@link #hasFeature}.
 */
public XMLLib.Factory getE4xImplementationFactory() {
  return getFactory().getE4xImplementationFactory();
}

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

/**
 * Create class loader for generated classes.
 * The method calls {@link ContextFactory#createClassLoader(ClassLoader)}
 * using the result of {@link #getFactory()}.
 */
public GeneratedClassLoader createClassLoader(ClassLoader parent)
{
  ContextFactory f = getFactory();
  return f.createClassLoader(parent);
}

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

/**
  Returns an object which specifies an E4X implementation to use within
  this <code>Context</code>.  Note
  that the XMLLib.Factory interface should be considered experimental.
 
  The default implementation uses the implementation provided by this
  <code>Context</code>'s {@link ContextFactory}.
 
  @return An XMLLib.Factory.  Should not return <code>null</code> if
    {@link #FEATURE_E4X} is enabled.  See {@link #hasFeature}.
 */
public XMLLib.Factory getE4xImplementationFactory() {
  return getFactory().getE4xImplementationFactory();
}

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

/**
 * Create class loader for generated classes.
 * The method calls {@link ContextFactory#createClassLoader(ClassLoader)}
 * using the result of {@link #getFactory()}.
 */
public GeneratedClassLoader createClassLoader(ClassLoader parent)
{
  ContextFactory f = getFactory();
  return f.createClassLoader(parent);
}

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

/**
 * Create class loader for generated classes.
 * The method calls {@link ContextFactory#createClassLoader(ClassLoader)}
 * using the result of {@link #getFactory()}.
 */
public GeneratedClassLoader createClassLoader(ClassLoader parent)
{
  ContextFactory f = getFactory();
  return f.createClassLoader(parent);
}

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

/**
 * Create class loader for generated classes.
 * The method calls {@link ContextFactory#createClassLoader(ClassLoader)}
 * using the result of {@link #getFactory()}.
 */
public GeneratedClassLoader createClassLoader(ClassLoader parent)
{
  ContextFactory f = getFactory();
  return f.createClassLoader(parent);
}

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

/**
 * Create class loader for generated classes.
 * The method calls {@link ContextFactory#createClassLoader(ClassLoader)}
 * using the result of {@link #getFactory()}.
 */
public GeneratedClassLoader createClassLoader(ClassLoader parent)
{
  ContextFactory f = getFactory();
  return f.createClassLoader(parent);
}

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

/**
 * Returns an object which specifies an E4X implementation to use within
 * this <code>Context</code>. Note that the XMLLib.Factory interface should
 * be considered experimental.
 *
 * The default implementation uses the implementation provided by this
 * <code>Context</code>'s {@link ContextFactory}.
 *
 * @return An XMLLib.Factory. Should not return <code>null</code> if
 *         {@link #FEATURE_E4X} is enabled. See {@link #hasFeature}.
 */
public XMLLib.Factory getE4xImplementationFactory() {
  return getFactory().getE4xImplementationFactory();
}

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

/**
 * Returns an object which specifies an E4X implementation to use within
 * this <code>Context</code>. Note that the XMLLib.Factory interface should
 * be considered experimental.
 *
 * The default implementation uses the implementation provided by this
 * <code>Context</code>'s {@link ContextFactory}.
 *
 * @return An XMLLib.Factory. Should not return <code>null</code> if
 *         {@link #FEATURE_E4X} is enabled. See {@link #hasFeature}.
 */
public XMLLib.Factory getE4xImplementationFactory() {
  return getFactory().getE4xImplementationFactory();
}

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

/**
 * Returns an object which specifies an E4X implementation to use within
 * this <code>Context</code>. Note that the XMLLib.Factory interface should
 * be considered experimental.
 *
 * The default implementation uses the implementation provided by this
 * <code>Context</code>'s {@link ContextFactory}.
 *
 * @return An XMLLib.Factory. Should not return <code>null</code> if
 *         {@link #FEATURE_E4X} is enabled. See {@link #hasFeature}.
 */
public XMLLib.Factory getE4xImplementationFactory() {
  return getFactory().getE4xImplementationFactory();
}

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

/**
 * Returns an object which specifies an E4X implementation to use within
 * this <code>Context</code>. Note that the XMLLib.Factory interface should
 * be considered experimental.
 *
 * The default implementation uses the implementation provided by this
 * <code>Context</code>'s {@link ContextFactory}.
 *
 * @return An XMLLib.Factory. Should not return <code>null</code> if
 *         {@link #FEATURE_E4X} is enabled. See {@link #hasFeature}.
 */
public XMLLib.Factory getE4xImplementationFactory() {
  return getFactory().getE4xImplementationFactory();
}

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

/**
 * Allow application to monitor counter of executed script instructions
 * in Context subclasses.
 * Run-time calls this when instruction counting is enabled and the counter
 * reaches limit set by <code>setInstructionObserverThreshold()</code>.
 * The method is useful to observe long running scripts and if necessary
 * to terminate them.
 * <p>
 * The default implementation calls
 * {@link ContextFactory#observeInstructionCount(Context cx,
 *                                               int instructionCount)}
 * that allows to customize Context behavior without introducing
 * Context subclasses.
 *
 * @param instructionCount amount of script instruction executed since
 * last call to <code>observeInstructionCount</code>
 * @throws Error to terminate the script
 * @see #setOptimizationLevel(int)
 */
protected void observeInstructionCount(int instructionCount)
{
  ContextFactory f = getFactory();
  f.observeInstructionCount(this, instructionCount);
}

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

/**
 * Allow application to monitor counter of executed script instructions
 * in Context subclasses.
 * Run-time calls this when instruction counting is enabled and the counter
 * reaches limit set by <code>setInstructionObserverThreshold()</code>.
 * The method is useful to observe long running scripts and if necessary
 * to terminate them.
 * <p>
 * The default implementation calls
 * {@link ContextFactory#observeInstructionCount(Context cx,
 *                                               int instructionCount)}
 * that allows to customize Context behavior without introducing
 * Context subclasses.
 *
 * @param instructionCount amount of script instruction executed since
 * last call to <code>observeInstructionCount</code>
 * @throws Error to terminate the script
 * @see #setOptimizationLevel(int)
 */
protected void observeInstructionCount(int instructionCount)
{
  ContextFactory f = getFactory();
  f.observeInstructionCount(this, instructionCount);
}

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

/**
 * Allow application to monitor counter of executed script instructions
 * in Context subclasses.
 * Run-time calls this when instruction counting is enabled and the counter
 * reaches limit set by <code>setInstructionObserverThreshold()</code>.
 * The method is useful to observe long running scripts and if necessary
 * to terminate them.
 * <p>
 * The default implementation calls
 * {@link ContextFactory#observeInstructionCount(Context cx,
 *                                               int instructionCount)}
 * that allows to customize Context behavior without introducing
 * Context subclasses.
 *
 * @param instructionCount amount of script instruction executed since
 * last call to <code>observeInstructionCount</code>
 * @throws Error to terminate the script
 * @see #setOptimizationLevel(int)
 */
protected void observeInstructionCount(int instructionCount)
{
  ContextFactory f = getFactory();
  f.observeInstructionCount(this, instructionCount);
}

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

/**
 * Allow application to monitor counter of executed script instructions
 * in Context subclasses.
 * Run-time calls this when instruction counting is enabled and the counter
 * reaches limit set by <code>setInstructionObserverThreshold()</code>.
 * The method is useful to observe long running scripts and if necessary
 * to terminate them.
 * <p>
 * The default implementation calls
 * {@link ContextFactory#observeInstructionCount(Context cx,
 *                                               int instructionCount)}
 * that allows to customize Context behavior without introducing
 * Context subclasses.
 *
 * @param instructionCount amount of script instruction executed since
 * last call to <code>observeInstructionCount</code>
 * @throws Error to terminate the script
 * @see #setOptimizationLevel(int)
 */
protected void observeInstructionCount(int instructionCount)
{
  ContextFactory f = getFactory();
  f.observeInstructionCount(this, instructionCount);
}

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

public static Object doTopCall(Callable callable,
                Context cx, Scriptable scope,
                Scriptable thisObj, Object[] args)
{
  if (scope == null)
    throw new IllegalArgumentException();
  if (cx.topCallScope != null) throw new IllegalStateException();
  Object result;
  cx.topCallScope = ScriptableObject.getTopLevelScope(scope);
  cx.useDynamicScope = cx.hasFeature(Context.FEATURE_DYNAMIC_SCOPE);
  ContextFactory f = cx.getFactory();
  try {
    result = f.doTopCall(callable, cx, scope, thisObj, args);
  } finally {
    cx.topCallScope = null;
    // Cleanup cached references
    cx.cachedXMLLib = null;
    if (cx.currentActivationCall != null) {
      // Function should always call exitActivationFunction
      // if it creates activation record
      throw new IllegalStateException();
    }
  }
  return result;
}

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

public static Object doTopCall(Callable callable,
                Context cx, Scriptable scope,
                Scriptable thisObj, Object[] args)
{
  if (scope == null) throw new IllegalArgumentException();
  if (cx.topCallScope != null) throw new IllegalStateException();
  Object result;
  cx.topCallScope = ScriptableObject.getTopLevelScope(scope);
  cx.useDynamicScope = cx.hasFeature(Context.FEATURE_DYNAMIC_SCOPE);
  ContextFactory f = cx.getFactory();
  try {
    result = f.doTopCall(callable, cx, scope, thisObj, args);
  } finally {
    cx.topCallScope = null;
    // Cleanup cached references
    cx.cachedXMLLib = null;
    if (cx.currentActivationCall != null) {
      // Function should always call exitActivationFunction
      // if it creates activation record
      throw new IllegalStateException();
    }
  }
  return result;
}

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

public static Object doTopCall(Callable callable,
                Context cx, Scriptable scope,
                Scriptable thisObj, Object[] args)
{
  if (scope == null)
    throw new IllegalArgumentException();
  if (cx.topCallScope != null) throw new IllegalStateException();
  Object result;
  cx.topCallScope = ScriptableObject.getTopLevelScope(scope);
  cx.useDynamicScope = cx.hasFeature(Context.FEATURE_DYNAMIC_SCOPE);
  ContextFactory f = cx.getFactory();
  try {
    result = f.doTopCall(callable, cx, scope, thisObj, args);
  } finally {
    cx.topCallScope = null;
    // Cleanup cached references
    cx.cachedXMLLib = null;
    if (cx.currentActivationCall != null) {
      // Function should always call exitActivationFunction
      // if it creates activation record
      throw new IllegalStateException();
    }
  }
  return result;
}

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

/**
 * Close the generator if it is still open.
 */
@Override
public void finalize() throws Throwable {
  if (savedState != null) {
    // This is a little tricky since we are most likely running in
    // a different thread. We need to get a Context to run this, and
    // we must call "doTopCall" since this will likely be the outermost
    // JavaScript frame on this thread.
    Context cx = Context.getCurrentContext();
    ContextFactory factory = cx != null ? cx.getFactory()
                      : ContextFactory.getGlobal();
    factory.call(new CloseGeneratorAction(this));
  }
}

相关文章

微信公众号

Context类方法