public class ExpressionEvaluatingRequestHandlerAdvice extends AbstractRequestHandlerAdvice
MessageHandler
s.
Two expressions 'onSuccessExpression' and 'onFailureExpression' are evaluated when
appropriate. If the evaluation returns a result, a message is sent to the onSuccessChannel
or onFailureChannel as appropriate; the message is the input message with a header
MessageHeaders.POSTPROCESS_RESULT
containing the evaluation result.
The failure expression is NOT evaluated if the success expression throws an exception.Modifier and Type | Class and Description |
---|---|
static class |
ExpressionEvaluatingRequestHandlerAdvice.MessageHandlingExpressionEvaluatingAdviceException |
AbstractRequestHandlerAdvice.ExecutionCallback
logger
Constructor and Description |
---|
ExpressionEvaluatingRequestHandlerAdvice() |
Modifier and Type | Method and Description |
---|---|
protected org.springframework.expression.spel.support.StandardEvaluationContext |
createEvaluationContext() |
protected java.lang.Object |
doInvoke(AbstractRequestHandlerAdvice.ExecutionCallback callback,
java.lang.Object target,
Message<?> message)
Subclasses implement this method to apply behavior to the
MessageHandler . |
void |
setFailureChannel(MessageChannel failureChannel) |
void |
setOnFailureExpression(java.lang.String onFailureExpression) |
void |
setOnSuccessExpression(java.lang.String onSuccessExpression) |
void |
setPropagateEvaluationFailures(boolean propagateOnSuccessEvaluationFailures)
If true and an onSuccess expression evaluation fails with an exception, the exception will be thrown to the
caller.
|
void |
setReturnFailureExpressionResult(boolean returnFailureExpressionResult)
If true, the result of evaluating the onFailureExpression will
be returned as the result of AbstractReplyProducingMessageHandler.handleRequestMessage(Message).
|
void |
setSuccessChannel(MessageChannel successChannel) |
void |
setTrapException(boolean trapException)
If true, any exception will be caught and null returned.
|
invoke, unwrapExceptionIfNecessary, unwrapThrowableIfNecessary
afterPropertiesSet, getApplicationContextId, getBeanFactory, getComponentName, getComponentType, getConversionService, getIntegrationProperties, getIntegrationProperty, getTaskScheduler, onInit, setApplicationContext, setBeanFactory, setBeanName, setComponentName, setConversionService, setTaskScheduler, toString
public ExpressionEvaluatingRequestHandlerAdvice()
public void setOnSuccessExpression(java.lang.String onSuccessExpression)
public void setOnFailureExpression(java.lang.String onFailureExpression)
public void setSuccessChannel(MessageChannel successChannel)
public void setFailureChannel(MessageChannel failureChannel)
public void setTrapException(boolean trapException)
trapException
- public void setReturnFailureExpressionResult(boolean returnFailureExpressionResult)
returnFailureExpressionResult
- public void setPropagateEvaluationFailures(boolean propagateOnSuccessEvaluationFailures)
propagateOnSuccessEvaluationFailures
- protected java.lang.Object doInvoke(AbstractRequestHandlerAdvice.ExecutionCallback callback, java.lang.Object target, Message<?> message) throws java.lang.Exception
AbstractRequestHandlerAdvice
MessageHandler
.
callback.execute() invokes the handler method and returns its result, or null.
doInvoke
in class AbstractRequestHandlerAdvice
callback
- Subclasses invoke the execute() method on this interface to invoke the handler method.target
- The target handler.message
- The message that will be sent to the handler.MessageHandler
.java.lang.Exception
protected org.springframework.expression.spel.support.StandardEvaluationContext createEvaluationContext()