Package org.springframework.retry.policy
Class ExpressionRetryPolicy
java.lang.Object
org.springframework.retry.policy.SimpleRetryPolicy
org.springframework.retry.policy.ExpressionRetryPolicy
- All Implemented Interfaces:
Serializable,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanFactoryAware,RetryPolicy
public class ExpressionRetryPolicy
extends SimpleRetryPolicy
implements org.springframework.beans.factory.BeanFactoryAware
Subclass of
SimpleRetryPolicy that delegates to super.canRetry() and, if true,
further evaluates an expression against the last thrown exception.- Since:
- 1.2
- Author:
- Gary Russell, Aldo Sinanaj, Artem Bilan
- See Also:
-
Field Summary
Fields inherited from class org.springframework.retry.policy.SimpleRetryPolicy
DEFAULT_MAX_ATTEMPTSFields inherited from interface org.springframework.retry.RetryPolicy
NO_MAXIMUM_ATTEMPTS_SET -
Constructor Summary
ConstructorsConstructorDescriptionExpressionRetryPolicy(int maxAttempts, Map<Class<? extends Throwable>, Boolean> retryableExceptions, boolean traverseCauses, String expressionString, boolean defaultValue) Construct an instance with the provided expression.ExpressionRetryPolicy(int maxAttempts, Map<Class<? extends Throwable>, Boolean> retryableExceptions, boolean traverseCauses, org.springframework.expression.Expression expression) Construct an instance with the providedExpression.ExpressionRetryPolicy(String expressionString) Construct an instance with the provided expression.ExpressionRetryPolicy(org.springframework.expression.Expression expression) Construct an instance with the providedExpression. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanRetry(RetryContext context) Test for retryable operation based on the status.static booleanisTemplate(String expression) Check if the expression is a templatevoidsetBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) withBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) Methods inherited from class org.springframework.retry.policy.SimpleRetryPolicy
close, getMaxAttempts, maxAttemptsSupplier, open, registerThrowable, setMaxAttempts, setNotRecoverable, toString
-
Constructor Details
-
ExpressionRetryPolicy
public ExpressionRetryPolicy(org.springframework.expression.Expression expression) Construct an instance with the providedExpression.- Parameters:
expression- the expression
-
ExpressionRetryPolicy
Construct an instance with the provided expression.- Parameters:
expressionString- the expression.
-
ExpressionRetryPolicy
public ExpressionRetryPolicy(int maxAttempts, Map<Class<? extends Throwable>, Boolean> retryableExceptions, boolean traverseCauses, org.springframework.expression.Expression expression) Construct an instance with the providedExpression.- Parameters:
maxAttempts- the max attemptsretryableExceptions- the exceptionstraverseCauses- true to examine causesexpression- the expression
-
ExpressionRetryPolicy
public ExpressionRetryPolicy(int maxAttempts, Map<Class<? extends Throwable>, Boolean> retryableExceptions, boolean traverseCauses, String expressionString, boolean defaultValue) Construct an instance with the provided expression.- Parameters:
maxAttempts- the max attemptsretryableExceptions- the exceptionstraverseCauses- true to examine causesexpressionString- the expression.defaultValue- the default action
-
-
Method Details
-
setBeanFactory
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException - Specified by:
setBeanFactoryin interfaceorg.springframework.beans.factory.BeanFactoryAware- Throws:
org.springframework.beans.BeansException
-
withBeanFactory
public ExpressionRetryPolicy withBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) -
canRetry
Description copied from class:SimpleRetryPolicyTest for retryable operation based on the status.- Specified by:
canRetryin interfaceRetryPolicy- Overrides:
canRetryin classSimpleRetryPolicy- Parameters:
context- the current retry status- Returns:
- true if the last exception was retryable and the number of attempts so far is less than the limit.
- See Also:
-
isTemplate
Check if the expression is a template- Parameters:
expression- the expression string- Returns:
- true if the expression string is a template
-