public class EBRetry<Result,Error> extends Object implements EBCallback<Result,Error>
Modifier and Type | Class and Description |
---|---|
static class |
EBRetry.WaitThread
Simple notify me in thread.
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
abort |
protected int |
attempts |
protected boolean |
cancel |
protected static String |
FIELD_STRATEGY_DATA |
protected static String |
FIELD_STRATEGY_TYPE |
protected EBRetryJob<Result,Error> |
job |
protected EBRetryJobError<Error> |
lastError |
protected Result |
lastResult |
protected boolean |
lastWasSuccess |
protected List<EBRetryListener<Result,Error>> |
listeners |
protected EBRetryStrategy |
retryStrategy |
protected boolean |
running |
protected boolean |
signalized |
protected boolean |
startedAsBlocking |
protected long |
waitingUntilMilli |
Constructor and Description |
---|
EBRetry() |
EBRetry(EBRetryJob<Result,Error> job) |
EBRetry(EBRetryStrategy retryStrategy) |
EBRetry(EBRetryStrategy retryStrategy,
EBRetryJob<Result,Error> job) |
EBRetry(int maxAttempts,
EBRetryJob<Result,Error> job) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(EBRetryListener<Result,Error> listener) |
void |
fromJSON(org.json.JSONObject json) |
int |
getAttempts() |
long |
getWaitingUntilMilli() |
boolean |
isAborted() |
boolean |
isCancelled() |
boolean |
isRunning() |
protected void |
notifyListenerFailed(EBRetryJobError<Error> error) |
protected void |
notifyListenerSuccess(Result result) |
void |
onFail(EBRetryJobError<Error> error,
boolean abort)
Job calls this callback.
|
void |
onSuccess(Result result)
Job calls this callback.
|
void |
onWaitFinished()
Called in async run - when waiting was finished.
|
void |
removeListener(EBRetryListener<Result,Error> listener) |
void |
reset() |
EBFuture<Result,Error> |
runAsync()
Runs the job asynchronously.
|
EBFuture<Result,Error> |
runAsync(EBRetryJob<Result,Error> job) |
protected void |
runAsyncInternal() |
Result |
runSync()
Blocking version of the run.
|
void |
setJob(EBRetryJob<Result,Error> job) |
org.json.JSONObject |
toJSON(org.json.JSONObject json) |
protected static final String FIELD_STRATEGY_TYPE
protected static final String FIELD_STRATEGY_DATA
protected int attempts
protected EBRetryStrategy retryStrategy
protected final List<EBRetryListener<Result,Error>> listeners
protected EBRetryJob<Result,Error> job
protected volatile boolean signalized
protected volatile boolean running
protected volatile boolean cancel
protected volatile boolean abort
protected volatile long waitingUntilMilli
protected boolean lastWasSuccess
protected boolean startedAsBlocking
protected Result lastResult
protected EBRetryJobError<Error> lastError
public EBRetry()
public EBRetry(EBRetryStrategy retryStrategy)
public EBRetry(int maxAttempts, EBRetryJob<Result,Error> job)
public EBRetry(EBRetryStrategy retryStrategy, EBRetryJob<Result,Error> job)
public EBRetry(EBRetryJob<Result,Error> job)
public EBFuture<Result,Error> runAsync()
protected void runAsyncInternal()
public Result runSync() throws EBRetryException
EBRetryException
- retry failedpublic void onSuccess(Result result)
onSuccess
in interface EBCallback<Result,Error>
result
- result of the jobpublic void onFail(EBRetryJobError<Error> error, boolean abort)
onFail
in interface EBCallback<Result,Error>
error
- error causing the job to failabort
- if true abort the call.public void onWaitFinished()
public int getAttempts()
public void reset()
public void addListener(EBRetryListener<Result,Error> listener)
public void removeListener(EBRetryListener<Result,Error> listener)
public void setJob(EBRetryJob<Result,Error> job)
public long getWaitingUntilMilli()
public boolean isRunning()
public boolean isCancelled()
public boolean isAborted()
public org.json.JSONObject toJSON(org.json.JSONObject json)
public void fromJSON(org.json.JSONObject json)
protected void notifyListenerSuccess(Result result)
protected void notifyListenerFailed(EBRetryJobError<Error> error)
Copyright © 2016. All rights reserved.