Class GroovyScriptExecutingMessageProcessor

java.lang.Object
org.springframework.integration.scripting.AbstractScriptExecutingMessageProcessor<Object>
org.springframework.integration.groovy.GroovyScriptExecutingMessageProcessor
All Implemented Interfaces:
Aware, BeanClassLoaderAware, BeanFactoryAware, InitializingBean, MessageProcessor<Object>

public class GroovyScriptExecutingMessageProcessor extends AbstractScriptExecutingMessageProcessor<Object> implements InitializingBean
The MessageProcessor implementation to evaluate Groovy scripts.
Since:
2.0
Author:
Dave Syer, Mark Fisher, Oleg Zhurakousky, Stefan Reuter, Artem Bilan, Gary Russell
  • Constructor Details

    • GroovyScriptExecutingMessageProcessor

      public GroovyScriptExecutingMessageProcessor(ScriptSource scriptSource)
      Create a processor for the given ScriptSource that will use a DefaultScriptVariableGenerator.
      Parameters:
      scriptSource - The script source.
    • GroovyScriptExecutingMessageProcessor

      public GroovyScriptExecutingMessageProcessor(ScriptSource scriptSource, ScriptVariableGenerator scriptVariableGenerator)
      Create a processor for the given ScriptSource that will use the provided ScriptVariableGenerator.
      Parameters:
      scriptSource - The script source.
      scriptVariableGenerator - The variable generator.
  • Method Details

    • setCustomizer

      public void setCustomizer(GroovyObjectCustomizer customizer)
      Sets a GroovyObjectCustomizer for this processor.
      Parameters:
      customizer - The customizer.
    • setCompileStatic

      public void setCompileStatic(boolean compileStatic)
      Specify the boolean flag to indicate if the GroovyClassLoader's compiler should be customised for the CompileStatic hint for the provided script.

      More compiler options can be provided via setCompilerConfiguration(CompilerConfiguration) overriding this flag.

      Parameters:
      compileStatic - the compile-static boolean flag.
      Since:
      4.3
      See Also:
      • CompileStatic
    • setCompilerConfiguration

      public void setCompilerConfiguration(org.codehaus.groovy.control.CompilerConfiguration compilerConfiguration)
      Specify the CompilerConfiguration options to customize the Groovy script compilation. For example the CompileStatic and ImportCustomizer are the most popular options.
      Parameters:
      compilerConfiguration - the Groovy script compiler options to use.
      Since:
      4.3
      See Also:
      • CompileStatic
      • GroovyClassLoader
    • getScriptSource

      protected ScriptSource getScriptSource(Message<?> message)
      Description copied from class: AbstractScriptExecutingMessageProcessor
      Subclasses must implement this method to create a script source, optionally using the message to locate or create the script.
      Specified by:
      getScriptSource in class AbstractScriptExecutingMessageProcessor<Object>
      Parameters:
      message - the message being processed
      Returns:
      a ScriptSource to use to create a script
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface InitializingBean
    • executeScript

      protected Object executeScript(ScriptSource scriptSource, Map<String,Object> variables)
      Description copied from class: AbstractScriptExecutingMessageProcessor
      Subclasses must implement this method. In doing so, the execution context for the script should be populated with the provided script variables.
      Specified by:
      executeScript in class AbstractScriptExecutingMessageProcessor<Object>
      Parameters:
      scriptSource - The script source.
      variables - The variables.
      Returns:
      The result of the execution.