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 Summary
Constructors Constructor Description GroovyScriptExecutingMessageProcessor(ScriptSource scriptSource)
Create a processor for the givenScriptSource
that will use a DefaultScriptVariableGenerator.GroovyScriptExecutingMessageProcessor(ScriptSource scriptSource, ScriptVariableGenerator scriptVariableGenerator)
Create a processor for the givenScriptSource
that will use the provided ScriptVariableGenerator. -
Method Summary
Modifier and Type Method Description void
afterPropertiesSet()
protected Object
executeScript(ScriptSource scriptSource, Map<String,Object> variables)
Subclasses must implement this method.protected ScriptSource
getScriptSource(Message<?> message)
Subclasses must implement this method to create a script source, optionally using the message to locate or create the script.void
setCompilerConfiguration(org.codehaus.groovy.control.CompilerConfiguration compilerConfiguration)
Specify theCompilerConfiguration
options to customize the Groovy script compilation.void
setCompileStatic(boolean compileStatic)
Specify theboolean
flag to indicate if theGroovyClassLoader
's compiler should be customised for theCompileStatic
hint for the provided script.void
setCustomizer(GroovyObjectCustomizer customizer)
Sets aGroovyObjectCustomizer
for this processor.Methods inherited from class org.springframework.integration.scripting.AbstractScriptExecutingMessageProcessor
getBeanClassLoader, getBeanFactory, getScriptVariableGenerator, processMessage, setBeanClassLoader, setBeanFactory
-
Constructor Details
-
GroovyScriptExecutingMessageProcessor
Create a processor for the givenScriptSource
that will use a DefaultScriptVariableGenerator.- Parameters:
scriptSource
- The script source.
-
GroovyScriptExecutingMessageProcessor
public GroovyScriptExecutingMessageProcessor(ScriptSource scriptSource, ScriptVariableGenerator scriptVariableGenerator)Create a processor for the givenScriptSource
that will use the provided ScriptVariableGenerator.- Parameters:
scriptSource
- The script source.scriptVariableGenerator
- The variable generator.
-
-
Method Details
-
setCustomizer
Sets aGroovyObjectCustomizer
for this processor.- Parameters:
customizer
- The customizer.
-
setCompileStatic
public void setCompileStatic(boolean compileStatic)Specify theboolean
flag to indicate if theGroovyClassLoader
's compiler should be customised for theCompileStatic
hint for the provided script.More compiler options can be provided via
setCompilerConfiguration(CompilerConfiguration)
overriding this flag.- Parameters:
compileStatic
- the compile staticboolean
flag.- Since:
- 4.3
- See Also:
CompileStatic
-
setCompilerConfiguration
public void setCompilerConfiguration(org.codehaus.groovy.control.CompilerConfiguration compilerConfiguration)Specify theCompilerConfiguration
options to customize the Groovy script compilation. For example theCompileStatic
andImportCustomizer
are the most popular options.- Parameters:
compilerConfiguration
- the Groovy script compiler options to use.- Since:
- 4.3
- See Also:
CompileStatic
,GroovyClassLoader
-
getScriptSource
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 classAbstractScriptExecutingMessageProcessor<Object>
- Parameters:
message
- the message being processed- Returns:
- a ScriptSource to use to create a script
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSet
in interfaceInitializingBean
-
executeScript
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 classAbstractScriptExecutingMessageProcessor<Object>
- Parameters:
scriptSource
- The script source.variables
- The variables.- Returns:
- The result of the execution.
-