com.octo.android.robospice.retry
Class DefaultRetryPolicy

java.lang.Object
  extended by com.octo.android.robospice.retry.DefaultRetryPolicy
All Implemented Interfaces:
RetryPolicy

public class DefaultRetryPolicy
extends Object
implements RetryPolicy

Default RetryPolicy implementation. Proposes an exponential back off algorithm. When getRetryCount() returns 0, the request is not retried anymore and will fail. Between each retry attempt, the request processor will sleep for getDelayBeforeRetry() milliseconds.

Author:
SNI

Field Summary
static float DEFAULT_BACKOFF_MULT
          The default backoff multiplier.
static long DEFAULT_DELAY_BEFORE_RETRY
          The default delay before retry a request (in ms).
static int DEFAULT_RETRY_COUNT
          The default number of retry attempts.
 
Constructor Summary
DefaultRetryPolicy()
           
DefaultRetryPolicy(int retryCount, long delayBeforeRetry, float backOffMultiplier)
           
 
Method Summary
 long getDelayBeforeRetry()
           
 int getRetryCount()
           
 void retry(SpiceException e)
          Hook method invoked when an exception occured.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_RETRY_COUNT

public static final int DEFAULT_RETRY_COUNT
The default number of retry attempts.

See Also:
Constant Field Values

DEFAULT_DELAY_BEFORE_RETRY

public static final long DEFAULT_DELAY_BEFORE_RETRY
The default delay before retry a request (in ms).

See Also:
Constant Field Values

DEFAULT_BACKOFF_MULT

public static final float DEFAULT_BACKOFF_MULT
The default backoff multiplier.

See Also:
Constant Field Values
Constructor Detail

DefaultRetryPolicy

public DefaultRetryPolicy(int retryCount,
                          long delayBeforeRetry,
                          float backOffMultiplier)

DefaultRetryPolicy

public DefaultRetryPolicy()
Method Detail

getRetryCount

public int getRetryCount()
Specified by:
getRetryCount in interface RetryPolicy
Returns:
the remaining number of retry attempts. When this method returns 0, request is not retried anymore.

retry

public void retry(SpiceException e)
Description copied from interface: RetryPolicy
Hook method invoked when an exception occured. Define your retry strategy here.

Specified by:
retry in interface RetryPolicy
Parameters:
e - the exception that occured during last request invocation.

getDelayBeforeRetry

public long getDelayBeforeRetry()
Specified by:
getDelayBeforeRetry in interface RetryPolicy
Returns:
the delay to sleep between each retry attempt (in ms).


Copyright © 2012-2014. All Rights Reserved.