Class PythonScriptExecutor

java.lang.Object
org.springframework.integration.scripting.jsr223.AbstractScriptExecutor
org.springframework.integration.scripting.jsr223.PythonScriptExecutor
All Implemented Interfaces:
ScriptExecutor

public class PythonScriptExecutor
extends AbstractScriptExecutor
A ScriptExecutor that implements special handling required for Python to emulate behavior similar to other JSR223 scripting languages.

Script evaluation using the Jython implementation results in a null return value for normal variable expressions such as x=2. As a work around, it is necessary to get the value of 'x' explicitly following the script evaluation. This class performs simple parsing on the last line of the script to obtain the variable name, if any, and return its value.

Since:
2.1
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static class  PythonScriptExecutor.PythonVariableParser  
  • Field Summary

    Fields inherited from class org.springframework.integration.scripting.jsr223.AbstractScriptExecutor

    logger
  • Constructor Summary

    Constructors 
    Constructor Description
    PythonScriptExecutor()  
  • Method Summary

    Modifier and Type Method Description
    protected java.lang.Object postProcess​(java.lang.Object result, javax.script.ScriptEngine scriptEngine, java.lang.String script, javax.script.Bindings bindings)
    Subclasses may implement this to provide any special handling required

    Methods inherited from class org.springframework.integration.scripting.jsr223.AbstractScriptExecutor

    executeScript, getScriptEngine

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.integration.scripting.ScriptExecutor

    executeScript
  • Constructor Details

  • Method Details

    • postProcess

      protected java.lang.Object postProcess​(java.lang.Object result, javax.script.ScriptEngine scriptEngine, java.lang.String script, javax.script.Bindings bindings)
      Description copied from class: AbstractScriptExecutor
      Subclasses may implement this to provide any special handling required
      Specified by:
      postProcess in class AbstractScriptExecutor
      Parameters:
      result - the result.
      scriptEngine - the engine.
      script - the script.
      bindings - the bindings.
      Returns:
      modified result