Class ExpressionEvaluatingMessageProcessor<T>

Type Parameters:
T - the expected payload type.
All Implemented Interfaces:
Aware, BeanFactoryAware, InitializingBean, MessageProcessor<T>

public class ExpressionEvaluatingMessageProcessor<T> extends AbstractMessageProcessor<T>
A MessageProcessor implementation that evaluates a SpEL expression with the Message itself as the root object within the evaluation context.
Since:
2.0
Author:
Mark Fisher, Artem Bilan, Gary Russell
  • Constructor Details

    • ExpressionEvaluatingMessageProcessor

      public ExpressionEvaluatingMessageProcessor(Expression expression)
      Create an ExpressionEvaluatingMessageProcessor for the given expression.
      Parameters:
      expression - The expression.
    • ExpressionEvaluatingMessageProcessor

      public ExpressionEvaluatingMessageProcessor(Expression expression, @Nullable Class<T> expectedType)
      Create an ExpressionEvaluatingMessageProcessor for the given expression and expected type for its evaluation result.
      Parameters:
      expression - The expression.
      expectedType - The expected type.
    • ExpressionEvaluatingMessageProcessor

      public ExpressionEvaluatingMessageProcessor(String expression)
      Create an ExpressionEvaluatingMessageProcessor for the given expression.
      Parameters:
      expression - a SpEL expression to evaluate.
      Since:
      5.0
    • ExpressionEvaluatingMessageProcessor

      public ExpressionEvaluatingMessageProcessor(String expression, @Nullable Class<T> expectedType)
      Construct ExpressionEvaluatingMessageProcessor for the provided SpEL expression and expected result type.
      Parameters:
      expression - a SpEL expression to evaluate.
      expectedType - the expected result type.
      Since:
      5.0
  • Method Details

    • processMessage

      public T processMessage(Message<?> message)
      Processes the Message by evaluating the expression with that Message as the root object. The expression evaluation result Object will be returned.
      Specified by:
      processMessage in interface MessageProcessor<T>
      Specified by:
      processMessage in class AbstractMessageProcessor<T>
      Parameters:
      message - The message.
      Returns:
      The result of processing the message.
    • toString

      public String toString()
      Overrides:
      toString in class Object