org.alfresco.ibatis
Class RetryingCallbackHelper

java.lang.Object
  extended by org.alfresco.ibatis.RetryingCallbackHelper

public class RetryingCallbackHelper
extends java.lang.Object

A helper that runs a unit of work, transparently retrying the unit of work if an error occurs.

Defaults:

Since:
3.4

Nested Class Summary
static interface RetryingCallbackHelper.RetryingCallback
          Callback interface
 
Constructor Summary
RetryingCallbackHelper()
          Default constructor.
 
Method Summary
 java.lang.Object doWithRetry(RetryingCallbackHelper.RetryingCallback 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RetryingCallbackHelper

public RetryingCallbackHelper()
Default constructor.

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 java.lang.Object doWithRetry(RetryingCallbackHelper.RetryingCallback 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


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.