ehcache

net.sf.ehcache.constructs.asynchronous
Interface Command

All Superinterfaces:
java.io.Serializable

public interface Command
extends java.io.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 519 2007-07-27 07:11:45Z gregluck $
Author:
Greg Luck

Method Summary
 void execute()
          Executes the command.
 int getDelayBetweenAttemptsInSeconds()
           
 int getNumberOfAttempts()
           
 java.lang.Class[] getThrowablesToRetryOn()
          The AsynchronousCommandExecutor may also be fault tolerant.
 

Method Detail

execute

void execute()
             throws java.lang.Throwable
Executes the command. The command is successful if it does not throw an exception.

Throws:
java.lang.Throwable - A command could do anything and could throw any Exception or Error
See Also:
to set {@link Throwable}s that should are expected

getThrowablesToRetryOn

java.lang.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

getNumberOfAttempts

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.

getDelayBetweenAttemptsInSeconds

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.

ehcache