Package org.springframework.retry.policy
Class ExceptionClassifierRetryPolicy
java.lang.Object
org.springframework.retry.policy.ExceptionClassifierRetryPolicy
- All Implemented Interfaces:
Serializable
,RetryPolicy
A
RetryPolicy
that dynamically adapts to one of a set of injected policies
according to the value of the latest exception.- Author:
- Dave Syer
- See Also:
-
Field Summary
Fields inherited from interface org.springframework.retry.RetryPolicy
NO_MAXIMUM_ATTEMPTS_SET
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canRetry
(RetryContext context) Delegate to the policy currently activated in the context.void
close
(RetryContext context) Delegate to the policy currently activated in the context.open
(RetryContext parent) Create an active context that proxies a retry policy by choosing a target from the policy map.void
registerThrowable
(RetryContext context, Throwable throwable) Delegate to the policy currently activated in the context.void
setExceptionClassifier
(Classifier<Throwable, RetryPolicy> exceptionClassifier) Setter for an exception classifier.void
setPolicyMap
(Map<Class<? extends Throwable>, RetryPolicy> policyMap) Setter for policy map used to create a classifier.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.retry.RetryPolicy
getMaxAttempts
-
Constructor Details
-
ExceptionClassifierRetryPolicy
public ExceptionClassifierRetryPolicy()
-
-
Method Details
-
setPolicyMap
Setter for policy map used to create a classifier. Either this property or the exception classifier directly should be set, but not both.- Parameters:
policyMap
- a map of Throwable class toRetryPolicy
that will be used to create aClassifier
to locate a policy.
-
setExceptionClassifier
Setter for an exception classifier. The classifier is responsible for translating exceptions to concrete retry policies. Either this property or the policy map should be used, but not both.- Parameters:
exceptionClassifier
- ExceptionClassifier to use
-
canRetry
Delegate to the policy currently activated in the context.- Specified by:
canRetry
in interfaceRetryPolicy
- Parameters:
context
- the current retry status- Returns:
- true if the operation can proceed
- See Also:
-
close
Delegate to the policy currently activated in the context.- Specified by:
close
in interfaceRetryPolicy
- Parameters:
context
- a retry status created by theRetryPolicy.open(RetryContext)
method of this policy.- See Also:
-
open
Create an active context that proxies a retry policy by choosing a target from the policy map.- Specified by:
open
in interfaceRetryPolicy
- Parameters:
parent
- the parent context if we are in a nested retry.- Returns:
- a
RetryContext
object specific to this policy. - See Also:
-
registerThrowable
Delegate to the policy currently activated in the context.- Specified by:
registerThrowable
in interfaceRetryPolicy
- Parameters:
context
- the current status object.throwable
- the exception to throw- See Also:
-