com.gisgraphy.helper
Class RetryOnErrorTemplate<T>

java.lang.Object
  extended by com.gisgraphy.helper.RetryOnErrorTemplate<T>

public abstract class RetryOnErrorTemplate<T>
extends java.lang.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
           
 
Constructor Summary
RetryOnErrorTemplate()
           
 
Method Summary
 int getAlreadyTry()
           
 java.lang.String getLoggingSentence()
           
 int getNumberOfTimesToRetry()
           
 void setLoggingSentence(java.lang.String loggingSentence)
           
 T times(int numberOfTry)
           
abstract  T tryThat()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.slf4j.Logger logger
Constructor Detail

RetryOnErrorTemplate

public RetryOnErrorTemplate()
Method Detail

tryThat

public abstract T tryThat()
                   throws java.lang.Exception
Throws:
java.lang.Exception

times

public T times(int numberOfTry)
        throws java.lang.Exception
Throws:
java.lang.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 java.lang.String getLoggingSentence()
Returns:
the loggingSentence

setLoggingSentence

public void setLoggingSentence(java.lang.String loggingSentence)
Parameters:
loggingSentence - the loggingSentence to set


Copyright © 2010. All Rights Reserved.