Interface ScriptEvaluator

All Known Implementing Classes:
BshScriptEvaluator, GroovyScriptEvaluator, StandardScriptEvaluator

public interface ScriptEvaluator
Spring's strategy interface for evaluating a script.

Aside from language-specific implementations, Spring also ships a version based on the standard javax.script package (JSR-223): StandardScriptEvaluator.

Since:
4.0
Author:
Juergen Hoeller, Costin Leau
  • Method Details

    • evaluate

      @Nullable Object evaluate(ScriptSource script) throws ScriptCompilationException
      Evaluate the given script.
      Parameters:
      script - the ScriptSource for the script to evaluate
      Returns:
      the return value of the script, if any
      Throws:
      ScriptCompilationException - if the evaluator failed to read, compile or evaluate the script
    • evaluate

      @Nullable Object evaluate(ScriptSource script, @Nullable Map<String,Object> arguments) throws ScriptCompilationException
      Evaluate the given script with the given arguments.
      Parameters:
      script - the ScriptSource for the script to evaluate
      arguments - the key-value pairs to expose to the script, typically as script variables (may be null or empty)
      Returns:
      the return value of the script, if any
      Throws:
      ScriptCompilationException - if the evaluator failed to read, compile or evaluate the script