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.Modifier and Type | Class and Description |
---|---|
static class |
ExpressionEvaluatingRequestHandlerAdvice.MessageHandlingExpressionEvaluatingAdviceException |
AbstractRequestHandlerAdvice.ExecutionCallback
logger
EXPRESSION_PARSER
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,
org.springframework.messaging.Message<?> message)
Subclasses implement this method to apply behavior to the
MessageHandler . |
protected void |
onInit()
Subclasses may implement this for initialization logic.
|
void |
setExpressionOnFailure(org.springframework.expression.Expression onFailureExpression)
Deprecated.
in favor of
setOnFailureExpression(Expression) |
void |
setExpressionOnSuccess(org.springframework.expression.Expression onSuccessExpression)
Deprecated.
in favor of
setOnSuccessExpression(Expression) |
void |
setFailureChannel(org.springframework.messaging.MessageChannel failureChannel)
Set the channel to which to send the
ErrorMessage after evaluating the
failure expression. |
void |
setFailureChannelName(java.lang.String failureChannelName)
Set the channel name to which to send the
ErrorMessage after evaluating the
failure expression. |
void |
setOnFailureExpression(org.springframework.expression.Expression onFailureExpression)
Set the expression to evaluate against the root message after a failed
handler invocation.
|
void |
setOnFailureExpressionString(java.lang.String onFailureExpression)
Set the expression to evaluate against the root message after a failed
handler invocation.
|
void |
setOnSuccessExpression(org.springframework.expression.Expression onSuccessExpression)
Set the expression to evaluate against the message after a successful
handler invocation.
|
void |
setOnSuccessExpressionString(java.lang.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(org.springframework.messaging.MessageChannel successChannel)
Set the channel to which to send the
AdviceMessage after evaluating the
success expression. |
void |
setSuccessChannelName(java.lang.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, getApplicationContext, getApplicationContextId, getBeanFactory, 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(java.lang.String onSuccessExpression)
onSuccessExpression
- the SpEL expression.public void setOnSuccessExpression(org.springframework.expression.Expression onSuccessExpression)
onSuccessExpression
- the SpEL expression.@Deprecated public void setExpressionOnSuccess(org.springframework.expression.Expression onSuccessExpression)
setOnSuccessExpression(Expression)
onSuccessExpression
- the SpEL expression.public void setOnFailureExpressionString(java.lang.String onFailureExpression)
#exception
onFailureExpression
- the SpEL expression.public void setOnFailureExpression(org.springframework.expression.Expression onFailureExpression)
#exception
onFailureExpression
- the SpEL expression.@Deprecated public void setExpressionOnFailure(org.springframework.expression.Expression onFailureExpression)
setOnFailureExpression(Expression)
#exception
onFailureExpression
- the SpEL expression.public void setSuccessChannel(org.springframework.messaging.MessageChannel successChannel)
AdviceMessage
after evaluating the
success expression.successChannel
- the channel.public void setSuccessChannelName(java.lang.String successChannelName)
AdviceMessage
after evaluating
the success expression.successChannelName
- the channel name.public void setFailureChannel(org.springframework.messaging.MessageChannel failureChannel)
ErrorMessage
after evaluating the
failure expression.failureChannel
- the channel.public void setFailureChannelName(java.lang.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 java.lang.Exception
IntegrationObjectSupport
onInit
in class IntegrationObjectSupport
java.lang.Exception
- Any exception.protected java.lang.Object doInvoke(AbstractRequestHandlerAdvice.ExecutionCallback callback, java.lang.Object target, org.springframework.messaging.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
- Any Exception.protected org.springframework.expression.spel.support.StandardEvaluationContext createEvaluationContext()