Class RetryContextSupport
java.lang.Object
org.springframework.core.AttributeAccessorSupport
org.springframework.retry.context.RetryContextSupport
- All Implemented Interfaces:
Serializable
,org.springframework.core.AttributeAccessor
,RetryContext
public class RetryContextSupport
extends org.springframework.core.AttributeAccessorSupport
implements RetryContext
- Author:
- Dave Syer
- See Also:
-
Field Summary
Fields inherited from interface org.springframework.retry.RetryContext
CLOSED, EXHAUSTED, MAX_ATTEMPTS, NAME, NO_RECOVERY, RECOVERED, STATE_KEY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAccessor for the exception object that caused the current retry.Accessor for the parent context if retry blocks are nested.int
Counts the number of retry attempts.boolean
Public accessor for the exhausted flagRetryContext.setExhaustedOnly()
.void
registerThrowable
(Throwable throwable) Set the exception for the public interfaceRetryContext
, and also increment the retry count if the throwable is non-null.void
Signal to the framework that no more attempts should be made to try or retry the currentRetryCallback
.toString()
Methods inherited from class org.springframework.core.AttributeAccessorSupport
attributeNames, computeAttribute, copyAttributesFrom, equals, getAttribute, hasAttribute, hashCode, removeAttribute, setAttribute
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.core.AttributeAccessor
attributeNames, computeAttribute, getAttribute, hasAttribute, removeAttribute, setAttribute
-
Constructor Details
-
RetryContextSupport
-
-
Method Details
-
getParent
Description copied from interface:RetryContext
Accessor for the parent context if retry blocks are nested.- Specified by:
getParent
in interfaceRetryContext
- Returns:
- the parent or null if there is none.
-
isExhaustedOnly
public boolean isExhaustedOnly()Description copied from interface:RetryContext
Public accessor for the exhausted flagRetryContext.setExhaustedOnly()
.- Specified by:
isExhaustedOnly
in interfaceRetryContext
- Returns:
- true if the flag has been set.
-
setExhaustedOnly
public void setExhaustedOnly()Description copied from interface:RetryContext
Signal to the framework that no more attempts should be made to try or retry the currentRetryCallback
.- Specified by:
setExhaustedOnly
in interfaceRetryContext
-
getRetryCount
public int getRetryCount()Description copied from interface:RetryContext
Counts the number of retry attempts. Before the first attempt this counter is zero, and before the first and subsequent attempts it should increment accordingly.- Specified by:
getRetryCount
in interfaceRetryContext
- Returns:
- the number of retries.
-
getLastThrowable
Description copied from interface:RetryContext
Accessor for the exception object that caused the current retry.- Specified by:
getLastThrowable
in interfaceRetryContext
- Returns:
- the last exception that caused a retry, or possibly null. It will be null if this is the first attempt and it finishes successfully, but also if the enclosing policy decides not to provide it (e.g. because of concerns about memory usage).
-
registerThrowable
Set the exception for the public interfaceRetryContext
, and also increment the retry count if the throwable is non-null. AllRetryPolicy
implementations should use this method when they register the throwable. It should only be called once per retry attempt because it increments a counter. Use of this method is not enforced by the framework - it is a service provider contract for authors of policies.- Parameters:
throwable
- the exception that caused the current retry attempt to fail.
-
toString
-