Class MethodInvocationRetryListenerSupport
java.lang.Object
org.springframework.retry.listener.MethodInvocationRetryListenerSupport
- All Implemented Interfaces:
RetryListener
Empty method implementation of RetryListener
with focus on the AOP reflective
method invocations providing convenience retry listener type-safe (with a
`MethodInvocationRetryCallback` callback parameter) specific methods.
MethodInvocationRetryCallback
.- Since:
- 1.3
- Author:
- Marius Grama
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T,
E extends Throwable>
voidclose
(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) Called after the final attempt (successful or not).protected <T,
E extends Throwable>
voiddoClose
(RetryContext context, MethodInvocationRetryCallback<T, E> callback, Throwable throwable) Called after the final attempt (successful or not).protected <T,
E extends Throwable>
voiddoOnError
(RetryContext context, MethodInvocationRetryCallback<T, E> callback, Throwable throwable) Called after every unsuccessful attempt at a retry.protected <T,
E extends Throwable>
voiddoOnSuccess
(RetryContext context, MethodInvocationRetryCallback<T, E> callback, T result) Called after a successful attempt; allow the listener to throw a new exception to cause a retry (according to the retry policy), based on the result returned by theRetryCallback.doWithRetry(RetryContext)
protected <T,
E extends Throwable>
booleandoOpen
(RetryContext context, MethodInvocationRetryCallback<T, E> callback) Called before the first attempt in a retry.<T,
E extends Throwable>
voidonError
(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) Called after every unsuccessful attempt at a retry.<T,
E extends Throwable>
voidonSuccess
(RetryContext context, RetryCallback<T, E> callback, T result) Called after a successful attempt; allow the listener to throw a new exception to cause a retry (according to the retry policy), based on the result returned by theRetryCallback.doWithRetry(RetryContext)
<T,
E extends Throwable>
booleanopen
(RetryContext context, RetryCallback<T, E> callback) Called before the first attempt in a retry.
-
Constructor Details
-
MethodInvocationRetryListenerSupport
public MethodInvocationRetryListenerSupport()
-
-
Method Details
-
close
public <T,E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) Description copied from interface:RetryListener
Called after the final attempt (successful or not). Allow the listener to clean up any resource it is holding before control returns to the retry caller.- Specified by:
close
in interfaceRetryListener
- Type Parameters:
T
- the return valueE
- the exception type- Parameters:
context
- the currentRetryContext
.callback
- the currentRetryCallback
.throwable
- the last exception that was thrown by the callback.
-
onSuccess
public <T,E extends Throwable> void onSuccess(RetryContext context, RetryCallback<T, E> callback, T result) Description copied from interface:RetryListener
Called after a successful attempt; allow the listener to throw a new exception to cause a retry (according to the retry policy), based on the result returned by theRetryCallback.doWithRetry(RetryContext)
- Specified by:
onSuccess
in interfaceRetryListener
- Type Parameters:
T
- the return type.- Parameters:
context
- the currentRetryContext
.callback
- the currentRetryCallback
.result
- the result returned by the callback method.
-
onError
public <T,E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) Description copied from interface:RetryListener
Called after every unsuccessful attempt at a retry.- Specified by:
onError
in interfaceRetryListener
- Type Parameters:
T
- the return valueE
- the exception to throw- Parameters:
context
- the currentRetryContext
.callback
- the currentRetryCallback
.throwable
- the last exception that was thrown by the callback.
-
open
Description copied from interface:RetryListener
Called before the first attempt in a retry. For instance, implementers can set up state that is needed by the policies in theRetryOperations
. The whole retry can be vetoed by returning false from this method, in which case aTerminatedRetryException
will be thrown.- Specified by:
open
in interfaceRetryListener
- Type Parameters:
T
- the type of object returned by the callbackE
- the type of exception it declares may be thrown- Parameters:
context
- the currentRetryContext
.callback
- the currentRetryCallback
.- Returns:
- true if the retry should proceed.
-
doClose
protected <T,E extends Throwable> void doClose(RetryContext context, MethodInvocationRetryCallback<T, E> callback, Throwable throwable) Called after the final attempt (successful or not). Allow the listener to clean up any resource it is holding before control returns to the retry caller.- Type Parameters:
E
- the exception typeT
- the return value- Parameters:
context
- the currentRetryContext
.callback
- the currentRetryCallback
.throwable
- the last exception that was thrown by the callback.
-
doOnSuccess
protected <T,E extends Throwable> void doOnSuccess(RetryContext context, MethodInvocationRetryCallback<T, E> callback, T result) Called after a successful attempt; allow the listener to throw a new exception to cause a retry (according to the retry policy), based on the result returned by theRetryCallback.doWithRetry(RetryContext)
- Type Parameters:
T
- the return type.- Parameters:
context
- the currentRetryContext
.callback
- the currentRetryCallback
.result
- the result returned by the callback method.- Since:
- 2.0
-
doOnError
protected <T,E extends Throwable> void doOnError(RetryContext context, MethodInvocationRetryCallback<T, E> callback, Throwable throwable) Called after every unsuccessful attempt at a retry.- Type Parameters:
T
- the return valueE
- the exception to throw- Parameters:
context
- the currentRetryContext
.callback
- the currentRetryCallback
.throwable
- the last exception that was thrown by the callback.
-
doOpen
protected <T,E extends Throwable> boolean doOpen(RetryContext context, MethodInvocationRetryCallback<T, E> callback) Called before the first attempt in a retry. For instance, implementers can set up state that is needed by the policies in theRetryOperations
. The whole retry can be vetoed by returning false from this method, in which case aTerminatedRetryException
will be thrown.- Type Parameters:
T
- the type of object returned by the callbackE
- the type of exception it declares may be thrown- Parameters:
context
- the currentRetryContext
.callback
- the currentRetryCallback
.- Returns:
- true if the retry should proceed.
-