CompensableCommand interface
The CompensableCommand interface extends the Command interface.
A compensable command is one that has another command (a compensator) associated with it, so that the work of the first can be undone by the compensator. For example, a command that attempts to make an airline reservation followed by a hotel reservation can offer a compensating command that allows the user to cancel the airline reservation if the hotel reservation cannot be made.
The CompensableCommand interface declares one method:
- getCompensatingCommand
This method returns the command that can be used to undo the effects of the original command.
To create a compensable command, you write an interface that extends the CompensableCommand interface. Such interfaces typically extend the TargetableCommand interface as well. Implement the getCompensatingCommand method in the implementation class for your interface. You must also implement the compensating command.
Related tasks
Writing command interfaces
Related Reference
Command interface example application
Reference topic