Package org.alfresco.ibatis
Class RetryingCallbackHelper
- java.lang.Object
-
- org.alfresco.ibatis.RetryingCallbackHelper
-
public class RetryingCallbackHelper extends java.lang.ObjectA 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 interfaceRetryingCallbackHelper.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> RdoWithRetry(RetryingCallbackHelper.RetryingCallback<R> callback)Execute a callback until it succeeds, fails or until a maximum number of retries have been attempted.voidsetMaxRetries(int maxRetries)Set the maximimum number of retries.voidsetRetryWaitMs(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:
java.lang.RuntimeException- all checked exceptions are converted
-
-