Class SourceExecutableScript

Direct Known Subclasses:
ResourceExecutableScript

public class SourceExecutableScript extends CompiledExecutableScript
A script which is provided as source code.
Author:
Daniel Meyer
  • Field Details

    • scriptSource

      protected String scriptSource
      The source of the script.
    • shouldBeCompiled

      protected volatile boolean shouldBeCompiled
      Flag to signal if the script should be compiled
    • compiledScriptSourceDigest

      protected volatile String compiledScriptSourceDigest
      Digest of the processed script source used to produce the current CompiledExecutableScript.compiledScript. A null value indicates no compiled artifact is present.
  • Constructor Details

    • SourceExecutableScript

      public SourceExecutableScript(String language, String source)
  • Method Details

    • evaluate

      public Object evaluate(ScriptEngine engine, VariableScope variableScope, Bindings bindings)
      Overrides:
      evaluate in class CompiledExecutableScript
    • compileScript

      protected void compileScript(ScriptEngine engine, String processedScript)
    • compile

      public CompiledScript compile(ScriptEngine scriptEngine, String language, String src)
    • evaluateScript

      protected Object evaluateScript(ScriptEngine engine, String processedScript, Bindings bindings) throws ScriptException
      Throws:
      ScriptException
    • getScriptSource

      public String getScriptSource()
    • setScriptSource

      public void setScriptSource(String scriptSource)
      Sets the script source code. And invalidates any cached compilation result.
      Parameters:
      scriptSource - the new script source code
    • invalidateCompiledScript

      protected void invalidateCompiledScript()
      Invalidates all cached compilation state for this script instance.

      This method clears the currently cached compiled artifact and its associated source digest, and marks the script as eligible for compilation on the next evaluation. The method is synchronized to guarantee that cache reset is applied atomically with respect to concurrent evaluation and source updates.

    • isShouldBeCompiled

      public boolean isShouldBeCompiled()