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 givenScriptSourcethat will use a DefaultScriptVariableGenerator.GroovyScriptExecutingMessageProcessor(ScriptSource scriptSource, ScriptVariableGenerator scriptVariableGenerator)Create a processor for the givenScriptSourcethat will use the provided ScriptVariableGenerator. -
Method Summary
Modifier and Type Method Description voidafterPropertiesSet()protected ObjectexecuteScript(ScriptSource scriptSource, Map<String,Object> variables)Subclasses must implement this method.protected ScriptSourcegetScriptSource(Message<?> message)Subclasses must implement this method to create a script source, optionally using the message to locate or create the script.voidsetCompilerConfiguration(org.codehaus.groovy.control.CompilerConfiguration compilerConfiguration)Specify theCompilerConfigurationoptions to customize the Groovy script compilation.voidsetCompileStatic(boolean compileStatic)Specify thebooleanflag to indicate if theGroovyClassLoader's compiler should be customised for theCompileStatichint for the provided script.voidsetCustomizer(GroovyObjectCustomizer customizer)Sets aGroovyObjectCustomizerfor 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 givenScriptSourcethat will use a DefaultScriptVariableGenerator.- Parameters:
scriptSource- The script source.
-
GroovyScriptExecutingMessageProcessor
public GroovyScriptExecutingMessageProcessor(ScriptSource scriptSource, ScriptVariableGenerator scriptVariableGenerator)Create a processor for the givenScriptSourcethat will use the provided ScriptVariableGenerator.- Parameters:
scriptSource- The script source.scriptVariableGenerator- The variable generator.
-
-
Method Details
-
setCustomizer
Sets aGroovyObjectCustomizerfor this processor.- Parameters:
customizer- The customizer.
-
setCompileStatic
public void setCompileStatic(boolean compileStatic)Specify thebooleanflag to indicate if theGroovyClassLoader's compiler should be customised for theCompileStatichint for the provided script.More compiler options can be provided via
setCompilerConfiguration(CompilerConfiguration)overriding this flag.- Parameters:
compileStatic- the compile-staticbooleanflag.- Since:
- 4.3
- See Also:
CompileStatic
-
setCompilerConfiguration
public void setCompilerConfiguration(org.codehaus.groovy.control.CompilerConfiguration compilerConfiguration)Specify theCompilerConfigurationoptions to customize the Groovy script compilation. For example theCompileStaticandImportCustomizerare 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:AbstractScriptExecutingMessageProcessorSubclasses must implement this method to create a script source, optionally using the message to locate or create the script.- Specified by:
getScriptSourcein classAbstractScriptExecutingMessageProcessor<Object>- Parameters:
message- the message being processed- Returns:
- a ScriptSource to use to create a script
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceInitializingBean
-
executeScript
Description copied from class:AbstractScriptExecutingMessageProcessorSubclasses must implement this method. In doing so, the execution context for the script should be populated with the provided script variables.- Specified by:
executeScriptin classAbstractScriptExecutingMessageProcessor<Object>- Parameters:
scriptSource- The script source.variables- The variables.- Returns:
- The result of the execution.
-