Package org.alfresco.ibatis
Class RetryingCallbackHelper
- java.lang.Object
-
- org.alfresco.ibatis.RetryingCallbackHelper
-
public class RetryingCallbackHelper extends Object
A helper that runs a unit of work, transparently retrying the unit of work if an error occurs.Defaults:
- maxRetries: 5
- retryWaitMs: 10
- Since:
- 3.4
- Author:
- Derek Hulley
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
RetryingCallbackHelper.RetryingCallback<Result>
Callback interface
-
Constructor Summary
Constructors Constructor Description RetryingCallbackHelper()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <R> R
doWithRetry(RetryingCallbackHelper.RetryingCallback<R> callback)
Execute a callback until it succeeds, fails or until a maximum number of retries have been attempted.void
setMaxRetries(int maxRetries)
Set the maximimum number of retries.void
setRetryWaitMs(int retryWaitMs)
-
-
-
Method Detail
-
setMaxRetries
public void setMaxRetries(int maxRetries)
Set the maximimum number of retries. -1 for infinity.
-
setRetryWaitMs
public void setRetryWaitMs(int retryWaitMs)
-
doWithRetry
public <R> R doWithRetry(RetryingCallbackHelper.RetryingCallback<R> callback)
Execute a callback until it succeeds, fails or until a maximum number of retries have been attempted.- Parameters:
callback
- The callback containing the unit of work.- Returns:
- Returns the result of the unit of work.
- Throws:
RuntimeException
- all checked exceptions are converted
-
-