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
See Also:
  • Constructor Details

    • ExpressionRetryPolicy

      public ExpressionRetryPolicy(org.springframework.expression.Expression expression)
      Construct an instance with the provided Expression.
      Parameters:
      expression - the expression
    • ExpressionRetryPolicy

      public ExpressionRetryPolicy(String expressionString)
      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 provided Expression.
      Parameters:
      maxAttempts - the max attempts
      retryableExceptions - the exceptions
      traverseCauses - true to examine causes
      expression - 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 attempts
      retryableExceptions - the exceptions
      traverseCauses - true to examine causes
      expressionString - 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:
      setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
      Throws:
      org.springframework.beans.BeansException
    • withBeanFactory

      public ExpressionRetryPolicy withBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
    • canRetry

      public boolean canRetry(RetryContext context)
      Description copied from class: SimpleRetryPolicy
      Test for retryable operation based on the status.
      Specified by:
      canRetry in interface RetryPolicy
      Overrides:
      canRetry in class SimpleRetryPolicy
      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

      public static boolean isTemplate(String expression)
      Check if the expression is a template
      Parameters:
      expression - the expression string
      Returns:
      true if the expression string is a template