com.gisgraphy.helper
Class RetryOnErrorTemplate<T>
java.lang.Object
com.gisgraphy.helper.RetryOnErrorTemplate<T>
public abstract class RetryOnErrorTemplate<T>
- extends Object
Give the ability to retry a function multiple times if it fails.
usage :
RetryOnErrorTemplate<String> retryOnError = new RetryOnErrorTemplate<String>() {
public String tryThat() throws Exception {
return THE_RETURNED_VALUE;
}
};
retryOnError.times(3)
- Author:
- David Masclet
Field Summary |
protected static org.slf4j.Logger |
logger
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
logger
protected static final org.slf4j.Logger logger
RetryOnErrorTemplate
public RetryOnErrorTemplate()
tryThat
public abstract T tryThat()
throws Exception
- Throws:
Exception
times
public T times(int numberOfTry)
throws Exception
- Throws:
Exception
getAlreadyTry
public int getAlreadyTry()
- Returns:
- The number of times the code has already been try
getNumberOfTimesToRetry
public int getNumberOfTimesToRetry()
- Returns:
- The number of times the code should be try
getLoggingSentence
public String getLoggingSentence()
- Returns:
- the loggingSentence
setLoggingSentence
public void setLoggingSentence(String loggingSentence)
- Parameters:
loggingSentence
- the loggingSentence to set
Copyright © 2012. All Rights Reserved.