Package org.springframework.retry.policy
Class CompositeRetryPolicy
java.lang.Object
org.springframework.retry.policy.CompositeRetryPolicy
- All Implemented Interfaces:
Serializable,RetryPolicy
A
RetryPolicy that composes a list of other policies and delegates calls to
them in order.- Author:
- Dave Syer, Michael Minella, Emanuele Ivaldi
- See Also:
-
Field Summary
Fields inherited from interface org.springframework.retry.RetryPolicy
NO_MAXIMUM_ATTEMPTS_SET -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanRetry(RetryContext context) Delegate to the policies that were in operation when the context was created.voidclose(RetryContext context) Delegate to the policies that were in operation when the context was created.intCalled to understand if the policy has a fixed number of maximum attempts before failureopen(RetryContext parent) Creates a new context that copies the existing policies and keeps a list of the contexts from each one.voidregisterThrowable(RetryContext context, Throwable throwable) Delegate to the policies that were in operation when the context was created.voidsetOptimistic(boolean optimistic) Setter for optimistic.voidsetPolicies(RetryPolicy[] policies) Setter for policies.
-
Constructor Details
-
CompositeRetryPolicy
public CompositeRetryPolicy()
-
-
Method Details
-
setOptimistic
public void setOptimistic(boolean optimistic) Setter for optimistic.- Parameters:
optimistic- should this retry policy be optimistic
-
setPolicies
Setter for policies.- Parameters:
policies- theRetryPolicypolicies
-
canRetry
Delegate to the policies that were in operation when the context was created. If any of them cannot retry then return false, otherwise return true.- Specified by:
canRetryin interfaceRetryPolicy- Parameters:
context- theRetryContext- Returns:
- true if the operation can proceed
- See Also:
-
close
Delegate to the policies that were in operation when the context was created. If any of them fails to close the exception is propagated (and those later in the chain are closed before re-throwing).- Specified by:
closein interfaceRetryPolicy- Parameters:
context- theRetryContext- See Also:
-
open
Creates a new context that copies the existing policies and keeps a list of the contexts from each one.- Specified by:
openin interfaceRetryPolicy- Parameters:
parent- the parent context if we are in a nested retry.- Returns:
- a
RetryContextobject specific to this policy. - See Also:
-
registerThrowable
Delegate to the policies that were in operation when the context was created.- Specified by:
registerThrowablein interfaceRetryPolicy- Parameters:
context- the current status object.throwable- the exception to throw- See Also:
-
getMaxAttempts
public int getMaxAttempts()Description copied from interface:RetryPolicyCalled to understand if the policy has a fixed number of maximum attempts before failure- Specified by:
getMaxAttemptsin interfaceRetryPolicy- Returns:
- the lower 'maximum number of attempts before failure' between all policies
that have a 'maximum number of attempts before failure' set, if at least one is
present among the policies, return
RetryPolicy.NO_MAXIMUM_ATTEMPTS_SETotherwise
-