Class AbstractScriptExecutingMessageProcessor<T>
java.lang.Object
org.springframework.integration.scripting.AbstractScriptExecutingMessageProcessor<T>
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanClassLoaderAware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.integration.handler.MessageProcessor<T>
- Direct Known Subclasses:
ScriptExecutingMessageProcessor
public abstract class AbstractScriptExecutingMessageProcessor<T>
extends java.lang.Object
implements org.springframework.integration.handler.MessageProcessor<T>, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanFactoryAware
Base
MessageProcessor for scripting implementations to extend.- Since:
- 2.0
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractScriptExecutingMessageProcessor()protectedAbstractScriptExecutingMessageProcessor(ScriptVariableGenerator scriptVariableGenerator) -
Method Summary
Modifier and Type Method Description protected abstract TexecuteScript(org.springframework.scripting.ScriptSource scriptSource, java.util.Map<java.lang.String,java.lang.Object> variables)Subclasses must implement this method.protected java.lang.ClassLoadergetBeanClassLoader()protected org.springframework.beans.factory.BeanFactorygetBeanFactory()protected abstract org.springframework.scripting.ScriptSourcegetScriptSource(org.springframework.messaging.Message<?> message)Subclasses must implement this method to create a script source, optionally using the message to locate or create the script.protected ScriptVariableGeneratorgetScriptVariableGenerator()TprocessMessage(org.springframework.messaging.Message<?> message)Executes the script and returns the result.voidsetBeanClassLoader(java.lang.ClassLoader classLoader)voidsetBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
-
Constructor Details
-
AbstractScriptExecutingMessageProcessor
protected AbstractScriptExecutingMessageProcessor() -
AbstractScriptExecutingMessageProcessor
-
-
Method Details
-
setBeanClassLoader
public void setBeanClassLoader(java.lang.ClassLoader classLoader)- Specified by:
setBeanClassLoaderin interfaceorg.springframework.beans.factory.BeanClassLoaderAware
-
setBeanFactory
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException- Specified by:
setBeanFactoryin interfaceorg.springframework.beans.factory.BeanFactoryAware- Throws:
org.springframework.beans.BeansException
-
getScriptVariableGenerator
-
getBeanClassLoader
protected java.lang.ClassLoader getBeanClassLoader() -
getBeanFactory
protected org.springframework.beans.factory.BeanFactory getBeanFactory() -
processMessage
Executes the script and returns the result.- Specified by:
processMessagein interfaceorg.springframework.integration.handler.MessageProcessor<T>
-
getScriptSource
protected abstract org.springframework.scripting.ScriptSource getScriptSource(org.springframework.messaging.Message<?> message)Subclasses must implement this method to create a script source, optionally using the message to locate or create the script.- Parameters:
message- the message being processed- Returns:
- a ScriptSource to use to create a script
-
executeScript
@Nullable protected abstract T executeScript(org.springframework.scripting.ScriptSource scriptSource, java.util.Map<java.lang.String,java.lang.Object> variables)Subclasses must implement this method. In doing so, the execution context for the script should be populated with the provided script variables.- Parameters:
scriptSource- The script source.variables- The variables.- Returns:
- The result of the execution.
-