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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanRetry(RetryContext context) Delegate to the policy currently activated in the context.voidclose(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.voidregisterThrowable(RetryContext context, Throwable throwable) Delegate to the policy currently activated in the context.voidsetExceptionClassifier(Classifier<Throwable, RetryPolicy> exceptionClassifier) Setter for an exception classifier.voidsetPolicyMap(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, waitMethods 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 toRetryPolicythat will be used to create aClassifierto 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:
canRetryin 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:
closein 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:
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 policy currently activated in the context.- Specified by:
registerThrowablein interfaceRetryPolicy- Parameters:
context- the current status object.throwable- the exception to throw- See Also:
-