Class ExpressionEvaluatingRequestHandlerAdvice
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice
org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice
- All Implemented Interfaces:
- Advice,- Interceptor,- MethodInterceptor,- Aware,- BeanFactoryAware,- BeanNameAware,- InitializingBean,- ApplicationContextAware,- ExpressionCapable,- NamedComponent
Used to advise 
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.
 
 When expressions are not configured, but channels are, the default expression is evaluated
 just into a payload from the message.
- Since:
- 2.2
- Author:
- Gary Russell, Artem Bilan
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classNested classes/interfaces inherited from class org.springframework.integration.handler.advice.AbstractRequestHandlerAdviceAbstractRequestHandlerAdvice.ExecutionCallback, AbstractRequestHandlerAdvice.ThrowableHolderException
- 
Field SummaryFields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, logger
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected StandardEvaluationContextprotected ObjectdoInvoke(AbstractRequestHandlerAdvice.ExecutionCallback callback, Object target, Message<?> message) Subclasses implement this method to apply behavior to theMessageHandler.protected voidonInit()Subclasses may implement this for initialization logic.voidsetFailureChannel(MessageChannel failureChannel) Set the channel to which to send theErrorMessageafter evaluating the failure expression.voidsetFailureChannelName(String failureChannelName) Set the channel name to which to send theErrorMessageafter evaluating the failure expression.voidsetOnFailureExpression(Expression onFailureExpression) Set the expression to evaluate against the root message after a failed handler invocation.voidsetOnFailureExpressionString(String onFailureExpression) Set the expression to evaluate against the root message after a failed handler invocation.voidsetOnSuccessExpression(Expression onSuccessExpression) Set the expression to evaluate against the message after a successful handler invocation.voidsetOnSuccessExpressionString(String onSuccessExpression) Set the expression to evaluate against the message after a successful handler invocation.voidsetPropagateEvaluationFailures(boolean propagateOnSuccessEvaluationFailures) If true and an onSuccess expression evaluation fails with an exception, the exception will be thrown to the caller.voidsetReturnFailureExpressionResult(boolean returnFailureExpressionResult) If true, the result of evaluating the onFailureExpression will be returned as the result of AbstractReplyProducingMessageHandler.handleRequestMessage(Message).voidsetSuccessChannel(MessageChannel successChannel) Set the channel to which to send theAdviceMessageafter evaluating the success expression.voidsetSuccessChannelName(String successChannelName) Set the channel name to which to send theAdviceMessageafter evaluating the success expression.voidsetTrapException(boolean trapException) If true, any exception will be caught and null returned.Methods inherited from class org.springframework.integration.handler.advice.AbstractRequestHandlerAdviceinvoke, unwrapExceptionIfNecessary, unwrapThrowableIfNecessaryMethods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getComponentType, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
- 
Constructor Details- 
ExpressionEvaluatingRequestHandlerAdvicepublic ExpressionEvaluatingRequestHandlerAdvice()
 
- 
- 
Method Details- 
setOnSuccessExpressionStringSet the expression to evaluate against the message after a successful handler invocation. Defaults topayload, ifsuccessChannelis configured.- Parameters:
- onSuccessExpression- the SpEL expression.
- Since:
- 4.3.7
 
- 
setOnSuccessExpressionSet the expression to evaluate against the message after a successful handler invocation. Defaults topayload, ifsuccessChannelis configured.- Parameters:
- onSuccessExpression- the SpEL expression.
- Since:
- 5.0
 
- 
setOnFailureExpressionStringSet the expression to evaluate against the root message after a failed handler invocation. The exception is available as the variable#exception. Defaults topayload, iffailureChannelis configured.- Parameters:
- onFailureExpression- the SpEL expression.
- Since:
- 4.3.7
 
- 
setOnFailureExpressionSet the expression to evaluate against the root message after a failed handler invocation. The exception is available as the variable#exception. Defaults topayload, iffailureChannelis configured.- Parameters:
- onFailureExpression- the SpEL expression.
- Since:
- 5.0
 
- 
setSuccessChannelSet the channel to which to send theAdviceMessageafter evaluating the success expression.- Parameters:
- successChannel- the channel.
 
- 
setSuccessChannelNameSet the channel name to which to send theAdviceMessageafter evaluating the success expression.- Parameters:
- successChannelName- the channel name.
- Since:
- 4.3.7
 
- 
setFailureChannelSet the channel to which to send theErrorMessageafter evaluating the failure expression.- Parameters:
- failureChannel- the channel.
 
- 
setFailureChannelNameSet the channel name to which to send theErrorMessageafter evaluating the failure expression.- Parameters:
- failureChannelName- the channel name.
- Since:
- 4.3.7
 
- 
setTrapExceptionpublic void setTrapException(boolean trapException) If true, any exception will be caught and null returned. Default false.- Parameters:
- trapException- true to trap Exceptions.
 
- 
setReturnFailureExpressionResultpublic void setReturnFailureExpressionResult(boolean returnFailureExpressionResult) If true, the result of evaluating the onFailureExpression will be returned as the result of AbstractReplyProducingMessageHandler.handleRequestMessage(Message).- Parameters:
- returnFailureExpressionResult- true to return the result of the evaluation.
 
- 
setPropagateEvaluationFailurespublic void setPropagateEvaluationFailures(boolean propagateOnSuccessEvaluationFailures) If true and an onSuccess expression evaluation fails with an exception, the exception will be thrown to the caller. If false, the exception is caught. Default false. Ignored for onFailure expression evaluation - the original exception will be propagated (unless trapException is true).- Parameters:
- propagateOnSuccessEvaluationFailures- The propagateOnSuccessEvaluationFailures to set.
 
- 
onInitprotected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
- onInitin class- IntegrationObjectSupport
 
- 
doInvokeprotected Object doInvoke(AbstractRequestHandlerAdvice.ExecutionCallback callback, Object target, Message<?> message) Description copied from class:AbstractRequestHandlerAdviceSubclasses implement this method to apply behavior to theMessageHandler.callback.execute() invokes the handler method and returns its result, or null. - Specified by:
- doInvokein class- AbstractRequestHandlerAdvice
- Parameters:
- 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.
- Returns:
- the result after invoking the MessageHandler.
 
- 
createEvaluationContext
 
-