net.sf.ehcache.constructs.asynchronous

Interface Command

public interface Command extends Serializable

An asynchronous encapsulated command. Callers do not need to know what the command does.

Commands must be serializable, so that they be persisted to disk by ehcache.

The command can also be fault tolerant. It is made fault tolerant when getThrowablesToRetryOn is non null. Any Throwables thrown that are <instanceof a Throwable in the array are expected and will result in reexecution up to the maximum number of attempts, after the delay between repeats. allowing a delay each time.

Version: $Id: Command.java 59 2006-04-30 03:41:39Z gregluck $

Author: Greg Luck

Method Summary
voidexecute()
Executes the command.
intgetDelayBetweenAttemptsInSeconds()
intgetNumberOfAttempts()
Class[]getThrowablesToRetryOn()
The AsynchronousCommandExecutor may also be fault tolerant.

Method Detail

execute

public void execute()
Executes the command. The command is successful if it does not throw an exception.

Throws: Throwable A command could do anything and could throw any Exception or Error

See Also: to set Throwables that should are expected

getDelayBetweenAttemptsInSeconds

public int getDelayBetweenAttemptsInSeconds()

Returns: the delay between attempts, in seconds. A non-zero value implies fault tolerance and only makes sense if getThrowablesToRetryOn is non-null.

getNumberOfAttempts

public int getNumberOfAttempts()

Returns: the number of times the dispatcher should try to send the message. A non-zero value implies fault tolerance and only makes sense if getThrowablesToRetryOn is non-null.

getThrowablesToRetryOn

public Class[] getThrowablesToRetryOn()
The AsynchronousCommandExecutor may also be fault tolerant. This method returns a list of Throwable classes such that if one if thrown during an execute attempt the command will simply retry after an interval until it uses up all of its retry attempts. If a Throwable does occurs which is not in this list, an AsynchronousCommandException will be thrown and the command will be removed.

Returns: a list of Classs. It only makes sense for the list to contain Classes which are subclasses of Throwable