public class ExpressionEvaluatingRequestHandlerAdvice extends AbstractRequestHandlerAdvice
MessageHandlers.
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 an AdviceMessage
containing the evaluation result in its payload and the inputMessage property containing
the original message that was sent to the endpoint.
The failure expression is NOT evaluated if the success expression throws an exception.| Modifier and Type | Class and Description |
|---|---|
static class |
ExpressionEvaluatingRequestHandlerAdvice.MessageHandlingExpressionEvaluatingAdviceException |
AbstractRequestHandlerAdvice.ExecutionCallbackloggerEXPRESSION_PARSER| Constructor and Description |
|---|
ExpressionEvaluatingRequestHandlerAdvice() |
| Modifier and Type | Method and Description |
|---|---|
protected StandardEvaluationContext |
createEvaluationContext() |
protected Object |
doInvoke(AbstractRequestHandlerAdvice.ExecutionCallback callback,
Object target,
Message<?> message)
Subclasses implement this method to apply behavior to the
MessageHandler. |
protected void |
onInit()
Subclasses may implement this for initialization logic.
|
void |
setExpressionOnFailure(Expression onFailureExpression)
Set the expression to evaluate against the root message after a failed
handler invocation.
|
void |
setExpressionOnSuccess(Expression onSuccessExpression)
Set the expression to evaluate against the message after a successful
handler invocation.
|
void |
setFailureChannel(MessageChannel failureChannel)
Set the channel to which to send the
ErrorMessage after evaluating the
failure expression. |
void |
setFailureChannelName(String failureChannelName)
Set the channel name to which to send the
ErrorMessage after evaluating the
failure expression. |
void |
setOnFailureExpression(String onFailureExpression)
Deprecated.
since 4.3.7 in favor of
setOnFailureExpressionString(String) |
void |
setOnFailureExpressionString(String onFailureExpression)
Set the expression to evaluate against the root message after a failed
handler invocation.
|
void |
setOnSuccessExpression(String onSuccessExpression)
Deprecated.
since 4.3.7 in favor of
setOnSuccessExpressionString(String) |
void |
setOnSuccessExpressionString(String onSuccessExpression)
Set the expression to evaluate against the message after a successful
handler invocation.
|
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)
Set the channel to which to send the
AdviceMessage after evaluating the
success expression. |
void |
setSuccessChannelName(String successChannelName)
Set the channel name to which to send the
AdviceMessage after evaluating
the success expression. |
void |
setTrapException(boolean trapException)
If true, any exception will be caught and null returned.
|
invoke, unwrapExceptionIfNecessary, unwrapThrowableIfNecessaryafterPropertiesSet, extractTypeIfPossible, getApplicationContext, getApplicationContextId, getBeanFactory, getChannelResolver, getComponentName, getComponentType, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringpublic ExpressionEvaluatingRequestHandlerAdvice()
@Deprecated public void setOnSuccessExpression(String onSuccessExpression)
setOnSuccessExpressionString(String)onSuccessExpression - the SpEL expression.public void setOnSuccessExpressionString(String onSuccessExpression)
onSuccessExpression - the SpEL expression.public void setExpressionOnSuccess(Expression onSuccessExpression)
onSuccessExpression - the SpEL expression.@Deprecated public void setOnFailureExpression(String onFailureExpression)
setOnFailureExpressionString(String)#exceptiononFailureExpression - the SpEL expression.public void setOnFailureExpressionString(String onFailureExpression)
#exceptiononFailureExpression - the SpEL expression.public void setExpressionOnFailure(Expression onFailureExpression)
#exceptiononFailureExpression - the SpEL expression.public void setSuccessChannel(MessageChannel successChannel)
AdviceMessage after evaluating the
success expression.successChannel - the channel.public void setSuccessChannelName(String successChannelName)
AdviceMessage after evaluating
the success expression.successChannelName - the channel name.public void setFailureChannel(MessageChannel failureChannel)
ErrorMessage after evaluating the
failure expression.failureChannel - the channel.public void setFailureChannelName(String failureChannelName)
ErrorMessage after evaluating the
failure expression.failureChannelName - the channel name.public void setTrapException(boolean trapException)
trapException - true to trap Exceptions.public void setReturnFailureExpressionResult(boolean returnFailureExpressionResult)
returnFailureExpressionResult - true to return the result of the evaluation.public void setPropagateEvaluationFailures(boolean propagateOnSuccessEvaluationFailures)
propagateOnSuccessEvaluationFailures - The
propagateOnSuccessEvaluationFailures to set.protected void onInit()
throws Exception
IntegrationObjectSupportonInit in class IntegrationObjectSupportException - Any exception.protected Object doInvoke(AbstractRequestHandlerAdvice.ExecutionCallback callback, Object target, Message<?> message) throws Exception
AbstractRequestHandlerAdviceMessageHandler.
callback.execute() invokes the handler method and returns its result, or null.
doInvoke in class AbstractRequestHandlerAdvicecallback - 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.Exception - Any Exception.protected StandardEvaluationContext createEvaluationContext()