Spring Integration

org.springframework.integration.scripting
Class AbstractScriptExecutingMessageProcessor<T>

java.lang.Object
  extended by org.springframework.integration.scripting.AbstractScriptExecutingMessageProcessor<T>
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanFactoryAware, MessageProcessor<T>
Direct Known Subclasses:
GroovyCommandMessageProcessor, GroovyScriptExecutingMessageProcessor, ScriptExecutingMessageProcessor

public abstract class AbstractScriptExecutingMessageProcessor<T>
extends java.lang.Object
implements MessageProcessor<T>, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanFactoryAware

Base MessageProcessor for scripting implementations to extend.

Since:
2.0
Author:
Mark Fisher, Stefan Reuter

Constructor Summary
protected AbstractScriptExecutingMessageProcessor()
           
protected AbstractScriptExecutingMessageProcessor(ScriptVariableGenerator scriptVariableGenerator)
           
 
Method Summary
protected abstract  T executeScript(org.springframework.scripting.ScriptSource scriptSource, java.util.Map<java.lang.String,java.lang.Object> variables)
          Subclasses must implement this method.
protected  java.lang.ClassLoader getBeanClassLoader()
           
protected  org.springframework.beans.factory.BeanFactory getBeanFactory()
           
protected abstract  org.springframework.scripting.ScriptSource getScriptSource(Message<?> message)
          Subclasses must implement this method to create a script source, optionally using the message to locate or create the script.
 T processMessage(Message<?> message)
          Executes the script and returns the result.
 void setBeanClassLoader(java.lang.ClassLoader classLoader)
           
 void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractScriptExecutingMessageProcessor

protected AbstractScriptExecutingMessageProcessor()

AbstractScriptExecutingMessageProcessor

protected AbstractScriptExecutingMessageProcessor(ScriptVariableGenerator scriptVariableGenerator)
Method Detail

processMessage

public final T processMessage(Message<?> message)
Executes the script and returns the result.

Specified by:
processMessage in interface MessageProcessor<T>

setBeanClassLoader

public void setBeanClassLoader(java.lang.ClassLoader classLoader)
Specified by:
setBeanClassLoader in interface org.springframework.beans.factory.BeanClassLoaderAware

getBeanClassLoader

protected java.lang.ClassLoader getBeanClassLoader()

setBeanFactory

public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
                    throws org.springframework.beans.BeansException
Specified by:
setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
Throws:
org.springframework.beans.BeansException

getBeanFactory

protected org.springframework.beans.factory.BeanFactory getBeanFactory()

getScriptSource

protected abstract org.springframework.scripting.ScriptSource getScriptSource(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

protected abstract T executeScript(org.springframework.scripting.ScriptSource scriptSource,
                                   java.util.Map<java.lang.String,java.lang.Object> variables)
                            throws java.lang.Exception
Subclasses must implement this method. In doing so, the execution context for the script should be populated with the provided script variables.

Throws:
java.lang.Exception

Spring Integration