com.norconex.jef.exec
Class Rerunner

java.lang.Object
  extended by com.norconex.jef.exec.Rerunner

public class Rerunner
extends Object

Rerunner is responsible for executing IRerunnable instances. Upon reaching the maximum number of retries allowed, it will return the last exception encountered if there was one, or throw a RuntimeException if IRerunnable simply returned false.

Author:
Pascal Essiembre

Field Summary
static int DEFAULT_MAX_RERUN_ATTEMPTS
          Default maximum number of retries.
static long DEFAULT_RERUN_SLEEP_TIME
          Default wait time (milliseconds) between reruns.
 
Constructor Summary
Rerunner()
          Creates a new instance of Rerunner using the default maximum re-run attempts and default re-run wait time.
Rerunner(IExceptionFilter exceptionFilter)
          Creates a new instance of Rerunner which will re-run code triggering exceptions only if the given exception is accepted by the IExceptionFilter.
Rerunner(IExceptionFilter exceptionFilter, int maxRerunAttempts)
          Creates a new instance of Rerunner which will re-run code triggering exceptions only if the given exception is accepted by the IExceptionFilter.
Rerunner(IExceptionFilter exceptionFilter, int maxRerunAttempts, long sleepTime)
          /** Creates a new instance of Rerunner which will re-run code triggering exceptions only if the given exception is accepted by the IExceptionFilter.
Rerunner(int maxRerunAttempts)
          Creates a new instance of Rerunner using the default re-run wait time.
Rerunner(int maxRecoveryAttempts, long sleepTime)
          Creates a new instance of Rerunner.
 
Method Summary
 void run(IRerunnable rerunnable)
          Runs the IRerunnable instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_RERUN_ATTEMPTS

public static final int DEFAULT_MAX_RERUN_ATTEMPTS
Default maximum number of retries.

See Also:
Constant Field Values

DEFAULT_RERUN_SLEEP_TIME

public static final long DEFAULT_RERUN_SLEEP_TIME
Default wait time (milliseconds) between reruns.

See Also:
Constant Field Values
Constructor Detail

Rerunner

public Rerunner()
Creates a new instance of Rerunner using the default maximum re-run attempts and default re-run wait time.


Rerunner

public Rerunner(int maxRerunAttempts)
Creates a new instance of Rerunner using the default re-run wait time.

Parameters:
maxRerunAttempts - maximum number of execution attempts

Rerunner

public Rerunner(int maxRecoveryAttempts,
                long sleepTime)
Creates a new instance of Rerunner.

Parameters:
maxRecoveryAttempts - maximum number of execution attempts
sleepTime - number of milliseconds to wait between each executions

Rerunner

public Rerunner(IExceptionFilter exceptionFilter)
Creates a new instance of Rerunner which will re-run code triggering exceptions only if the given exception is accepted by the IExceptionFilter. Uses the default maximum re-run attempts and default re-run wait time.

Parameters:
exceptionFilter - exception filter

Rerunner

public Rerunner(IExceptionFilter exceptionFilter,
                int maxRerunAttempts)
Creates a new instance of Rerunner which will re-run code triggering exceptions only if the given exception is accepted by the IExceptionFilter. Uses the default re-run wait time.

Parameters:
exceptionFilter - exception filter
maxRerunAttempts - maximum number of execution attempts

Rerunner

public Rerunner(IExceptionFilter exceptionFilter,
                int maxRerunAttempts,
                long sleepTime)
/** Creates a new instance of Rerunner which will re-run code triggering exceptions only if the given exception is accepted by the IExceptionFilter.

Parameters:
exceptionFilter - exception filter
maxRerunAttempts - maximum number of execution attempts
sleepTime - number of milliseconds to wait between each executions
Method Detail

run

public void run(IRerunnable rerunnable)
         throws RerunnableException
Runs the IRerunnable instance.

Parameters:
rerunnable - the code to run
Throws:
RerunnableException - wrapper around last exception encountered or exeption thrown when max rerun attempts is reached.


Copyright © 2007-2013 Norconex Inc.. All Rights Reserved.