kd.bos.script.jsengine

## 类 KContext

- java.lang.Object
- - org.mozilla.javascript.Context
  - - kd.bos.script.jsengine.KContext

- 所有已实现的接口:
    ScriptContext

      public final class KContext
      extends Context
      implements ScriptContext

  上下文

- - ### 嵌套类概要

    - ### 从类继承的嵌套类/接口 org.mozilla.javascript.Context

      `Context.ClassShutterSetter`

  - ### 字段概要

    - ### 从类继承的字段 org.mozilla.javascript.Context

      `emptyArgs, errorReporterProperty, FEATURE_DYNAMIC_SCOPE, FEATURE_E4X, FEATURE_ENHANCED_JAVA_ACCESS, FEATURE_LOCATION_INFORMATION_IN_ERROR, FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME, FEATURE_NON_ECMA_GET_YEAR, FEATURE_PARENT_PROTO_PROPERTIES, FEATURE_PARENT_PROTO_PROPRTIES, FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER, FEATURE_STRICT_EVAL, FEATURE_STRICT_MODE, FEATURE_STRICT_VARS, FEATURE_TO_STRING_AS_SOURCE, FEATURE_V8_EXTENSIONS, FEATURE_WARNING_AS_ERROR, generateObserverCount, languageVersionProperty, VERSION_1_0, VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_DEFAULT, VERSION_ES6, VERSION_UNKNOWN`

  - ### 构造器概要

    构造器
    构造器和说明
    `KContext(org.mozilla.javascript.ContextFactory factory)` 安全模式：js中不能new任何java对象，必须通过外部KContext#def进去。

  - ### 方法概要

    所有方法 静态方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `void` | `__releaseAllScriptObject()`
    `void` | `addScriptObject(ScriptObject so)`
    `ScriptObject` | `createObject(java.lang.Class<? extends ScriptObject> scritableCls, java.lang.Object... constructArgs)` 创建js对象
    `org.mozilla.javascript.Scriptable` | `createObject(java.lang.String namespace, java.lang.String jsTypeName, java.lang.Object... constructArgs)`
    `void` | `end()`
    `static KContext` | `get()`
    `<T> T` | `get(java.lang.String var)` 获取变量
    `java.util.Set<ScriptClassInfo>` | `getAllDefinedClasses()` 已定义的类名(全部)
    `java.lang.ClassLoader` | `getClassLoader()`
    `KClassShutter` | `getClassShutter()`
    `long` | `getCurrentInstructions()`
    `long` | `getDebugTimeout()`
    `java.util.Set<ScriptClassInfo>` | `getDefinedClasses()` 已定义的类名(仅公开给用户使用的)
    `long` | `getMaxInstructions()`
    `KScope` | `getScope()`
    `ScriptLookup` | `getScriptLookup()`
    `KSecurityDomain` | `getSecurityDomain()`
    `long` | `getStartTime()`
    `long` | `getTimeout()`
    `VarProvider` | `getVarProvider()`
    `boolean` | `isDebugModel()`
    `boolean` | `isDefiningInnerClass()`
    `boolean` | `isSafeModel()`
    `void` | `maskDebug(boolean maskDebug)` DIM.attachTo时候给contextFactory增加了Listener(DimIProxy)， 这个DimIProxy在创建Context的时候设置了debugger。
    `void` | `registKSUtilPlugin(java.lang.String fileName, java.lang.String xxxx)`
    `void` | `require(java.lang.String... modulesOrClasses)` 引入module或KSObject标识的js类。
    `void` | `set(java.lang.String var, java.lang.Object value)` 设置scope变量
    `void` | `setConst(java.lang.String var, java.lang.Object value)` 设置scope常量
    `void` | `setCurrentInstructions(long currentInstructions)`
    `void` | `setLimit(long timeout, long debugTimeout, long maxInstructions, int instructionObserverThreshold)`
    `void` | `setScriptLookup(ScriptLookup scriptLookup)`
    `void` | `setSecurityDomain(KSecurityDomain securityDomain)`
    `void` | `setValidateModel(boolean validateModel)`
    `void` | `setVarProvider(VarProvider vp)` 设置动态变量提供者

    - ### 从类继承的方法 org.mozilla.javascript.Context

      `addActivationName, addContextListener, addPropertyChangeListener, call, call, callFunctionWithContinuations, captureContinuation, checkLanguageVersion, checkOptimizationLevel, compileFunction, compileReader, compileReader, compileString, createClassLoader, decompileFunction, decompileFunctionBody, decompileScript, enter, enter, evaluateReader, evaluateString, executeScriptWithContinuations, exit, getApplicationClassLoader, getClassShutterSetter, getCurrentContext, getDebuggableView, getDebugger, getDebuggerContextData, getE4xImplementationFactory, getElements, getErrorReporter, getFactory, getImplementationVersion, getInstructionObserverThreshold, getLanguageVersion, getLocale, getMaximumInterpreterStackDepth, getOptimizationLevel, getThreadLocal, getUndefinedValue, getWrapFactory, hasFeature, initSafeStandardObjects, initSafeStandardObjects, initSafeStandardObjects, initStandardObjects, initStandardObjects, initStandardObjects, isActivationNeeded, isGeneratingDebug, isGeneratingDebugChanged, isGeneratingSource, isSealed, isValidLanguageVersion, isValidOptimizationLevel, javaToJS, jsToJava, newArray, newArray, newObject, newObject, newObject, original_jsToJava, putThreadLocal, removeActivationName, removeContextListener, removePropertyChangeListener, removeThreadLocal, reportError, reportError, reportRuntimeError, reportRuntimeError, reportWarning, reportWarning, reportWarning, resumeContinuation, seal, setApplicationClassLoader, setCachingEnabled, setClassShutter, setDebugger, setErrorReporter, setGenerateObserverCount, setGeneratingDebug, setGeneratingSource, setInstructionObserverThreshold, setLanguageVersion, setLocale, setMaximumInterpreterStackDepth, setOptimizationLevel, setSecurityController, setWrapFactory, stringIsCompilableUnit, throwAsScriptRuntimeEx, toBoolean, toNumber, toObject, toObject, toString, toType, unseal`

    - ### 从类继承的方法 java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 构造器详细资料

    - #### KContext

          public KContext(org.mozilla.javascript.ContextFactory factory)

      安全模式：js中不能new任何java对象，必须通过外部KContext#def进去。

  - ### 方法详细资料

    - #### get

          public static KContext get()

    - #### setValidateModel

          public void setValidateModel(boolean validateModel)

    - #### maskDebug

          public void maskDebug(boolean maskDebug)

      DIM.attachTo时候给contextFactory增加了Listener(DimIProxy)， 这个DimIProxy在创建Context的时候设置了debugger。 而contextFactory是全局的，当有一次调试(挂了Listener)，后面的请求都会进入调试模式。 需要在执行前设置屏蔽debug模式。

    - #### isDebugModel

          public boolean isDebugModel()

      覆盖:
        `isDebugModel` 在类中 `Context`

    - #### isDefiningInnerClass

          public boolean isDefiningInnerClass()

    - #### registKSUtilPlugin

          public void registKSUtilPlugin(java.lang.String fileName,
                                         java.lang.String xxxx)

    - #### end

          public void end()

    - #### __releaseAllScriptObject

          public void __releaseAllScriptObject()

    - #### getScope

          public KScope getScope()

    - #### getClassShutter

          public KClassShutter getClassShutter()

    - #### get

          public <T> T get(java.lang.String var)

      从接口复制的说明: `ScriptContext`
      获取变量
      指定者:
        `get` 在接口中 `ScriptContext`

    - #### set

          public void set(java.lang.String var,
                          java.lang.Object value)

      设置scope变量
      指定者:
        `set` 在接口中 `ScriptContext`
      参数:
        `var` - 变量名称
        `value` - 普通java对象

    - #### setConst

          public void setConst(java.lang.String var,
                               java.lang.Object value)

      设置scope常量
      指定者:
        `setConst` 在接口中 `ScriptContext`

    - #### require

          public void require(java.lang.String... modulesOrClasses)

      从接口复制的说明: `ScriptContext`
      引入module或KSObject标识的js类。
      指定者:
        `require` 在接口中 `ScriptContext`
      参数:
        `modulesOrClasses` - module必含/字符，形如：/kd/bos/../xxx.conf class为KSObject类全路径，形如：kd.bos...Xxx

    - #### createObject

          public ScriptObject createObject(java.lang.Class<? extends ScriptObject> scritableCls,
                                           java.lang.Object... constructArgs)

      创建js对象

    - #### createObject

          public org.mozilla.javascript.Scriptable createObject(java.lang.String namespace,
                                                                java.lang.String jsTypeName,
                                                                java.lang.Object... constructArgs)

    - #### isSafeModel

          public final boolean isSafeModel()

    - #### getClassLoader

          public final java.lang.ClassLoader getClassLoader()

    - #### setLimit

          public void setLimit(long timeout,
                               long debugTimeout,
                               long maxInstructions,
                               int instructionObserverThreshold)

      参数:
        `timeout` - 脚本超时时间(毫秒)
        `debugTimeout` - 调试脚本超时时间
        `maxInstruction` - 最多指令数
        `instructionObserverThreshold` - 观察指令阀值：每执行这个指令数，进行一次超时检测。

    - #### getTimeout

          public long getTimeout()

    - #### getDebugTimeout

          public long getDebugTimeout()

    - #### getStartTime

          public long getStartTime()

    - #### getMaxInstructions

          public long getMaxInstructions()

    - #### getCurrentInstructions

          public long getCurrentInstructions()

    - #### setCurrentInstructions

          public void setCurrentInstructions(long currentInstructions)

    - #### getSecurityDomain

          public KSecurityDomain getSecurityDomain()

    - #### setSecurityDomain

          public void setSecurityDomain(KSecurityDomain securityDomain)

    - #### getScriptLookup

          public ScriptLookup getScriptLookup()

    - #### setScriptLookup

          public void setScriptLookup(ScriptLookup scriptLookup)

      指定者:
        `setScriptLookup` 在接口中 `ScriptContext`

    - #### addScriptObject

          public void addScriptObject(ScriptObject so)

    - #### setVarProvider

          public void setVarProvider(VarProvider vp)

      从接口复制的说明: `ScriptContext`
      设置动态变量提供者
      指定者:
        `setVarProvider` 在接口中 `ScriptContext`

    - #### getVarProvider

          public VarProvider getVarProvider()

    - #### getDefinedClasses

          public java.util.Set<ScriptClassInfo> getDefinedClasses()

      从接口复制的说明: `ScriptContext`
      已定义的类名(仅公开给用户使用的)
      指定者:
        `getDefinedClasses` 在接口中 `ScriptContext`

    - #### getAllDefinedClasses

          public java.util.Set<ScriptClassInfo> getAllDefinedClasses()

      从接口复制的说明: `ScriptContext`
      已定义的类名(全部)
      指定者:
        `getAllDefinedClasses` 在接口中 `ScriptContext`