org.springframework.integration.handler.advice
Class ExpressionEvaluatingRequestHandlerAdvice
java.lang.Object
org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice
org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice
- All Implemented Interfaces:
- org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware
public class ExpressionEvaluatingRequestHandlerAdvice
- extends AbstractRequestHandlerAdvice
- implements org.springframework.beans.factory.BeanFactoryAware
Used to advise 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.
- Since:
- 2.2
- Author:
- Gary Russell
Method Summary |
protected java.lang.Object |
doInvoke(AbstractRequestHandlerAdvice.ExecutionCallback callback,
java.lang.Object target,
Message<?> message)
|
void |
setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
|
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 |
setTrapException(boolean trapException)
If true, any exception will be caught and null returned. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ExpressionEvaluatingRequestHandlerAdvice
public ExpressionEvaluatingRequestHandlerAdvice(org.springframework.expression.Expression onSuccessExpression,
MessageChannel successChannel,
org.springframework.expression.Expression onFailureExpression,
MessageChannel failureChannel)
- Parameters:
onSuccessExpression
- successChannel
- onFailureExpression
- failureChannel
-
ExpressionEvaluatingRequestHandlerAdvice
public ExpressionEvaluatingRequestHandlerAdvice(java.lang.String onSuccessExpression,
MessageChannel successChannel,
java.lang.String onFailureExpression,
MessageChannel failureChannel)
setTrapException
public void setTrapException(boolean trapException)
- If true, any exception will be caught and null returned.
Default false.
- Parameters:
trapException
-
setReturnFailureExpressionResult
public void setReturnFailureExpressionResult(boolean returnFailureExpressionResult)
- If true, the result of evaluating the onFailureExpression will
be returned as the result of AbstractReplyProducingMessageHandler.handleRequestMessage(Message).
- Parameters:
returnFailureExpressionResult
-
setPropagateEvaluationFailures
public 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
-
setBeanFactory
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
throws org.springframework.beans.BeansException
- Specified by:
setBeanFactory
in interface org.springframework.beans.factory.BeanFactoryAware
- Throws:
org.springframework.beans.BeansException
doInvoke
protected java.lang.Object doInvoke(AbstractRequestHandlerAdvice.ExecutionCallback callback,
java.lang.Object target,
Message<?> message)
throws java.lang.Exception
- Specified by:
doInvoke
in class AbstractRequestHandlerAdvice
- Throws:
java.lang.Exception