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 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.
When expressions are not configured, but channels are, the default expression is evaluated
just into a payload
from the message.
Modifier and Type | Class and Description |
---|---|
static class |
ExpressionEvaluatingRequestHandlerAdvice.MessageHandlingExpressionEvaluatingAdviceException |
AbstractRequestHandlerAdvice.ExecutionCallback, AbstractRequestHandlerAdvice.ThrowableHolderException
EXPRESSION_PARSER, logger
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 |
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(Expression onFailureExpression)
Set the expression to evaluate against the root message after a failed
handler invocation.
|
void |
setOnFailureExpressionString(String onFailureExpression)
Set the expression to evaluate against the root message after a failed
handler invocation.
|
void |
setOnSuccessExpression(Expression onSuccessExpression)
Set the expression to evaluate against the message after a successful
handler invocation.
|
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, unwrapThrowableIfNecessary
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getComponentType, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
public ExpressionEvaluatingRequestHandlerAdvice()
public void setOnSuccessExpressionString(String onSuccessExpression)
payload
, if successChannel
is configured.onSuccessExpression
- the SpEL expression.public void setOnSuccessExpression(@Nullable Expression onSuccessExpression)
payload
, if successChannel
is configured.onSuccessExpression
- the SpEL expression.public void setOnFailureExpressionString(String onFailureExpression)
#exception
.
Defaults to payload
, if failureChannel
is configured.onFailureExpression
- the SpEL expression.public void setOnFailureExpression(@Nullable Expression onFailureExpression)
#exception
.
Defaults to payload
, if failureChannel
is configured.onFailureExpression
- 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()
IntegrationObjectSupport
onInit
in class IntegrationObjectSupport
protected Object doInvoke(AbstractRequestHandlerAdvice.ExecutionCallback callback, Object target, Message<?> message)
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
.protected StandardEvaluationContext createEvaluationContext()