com.ibm.websphere.command
Interface CompensableCommand

All Superinterfaces:
Command, java.io.Serializable

public interface CompensableCommand
extends Command

The CompensableCommand interface allows you to make a command reversible. When you make a command compensable, you associate a second command with it. The second command compensates for the effects of the first command by undoing its work as completely as possible.

The CompensableCommand interface defines one method, getCompensatingCommand(), which returns the compensating command associated with a command. The application programmer must implement both this method and the compensating command itself as part of implementing a compensable command.

A client that wants to reverse a compensable command calls the compensating command like this:

       myCommand.getCompensatingCommand().performExecute();
 


Fields inherited from interface com.ibm.websphere.command.Command
serialVersionUID
 
Method Summary
 Command getCompensatingCommand()
          Retrieves the compensating command associated with the command.
 
Methods inherited from interface com.ibm.websphere.command.Command
execute, isReadyToCallExecute, reset
 

Method Detail

getCompensatingCommand

public Command getCompensatingCommand()
                               throws CommandException
Retrieves the compensating command associated with the command. Call this method only after the associated compensable command has been run.

The application programmer implements the getCompensatingCommand method as part of writing a compensable command. For a compensating command whose input properties are the output properties of the original command, the following implementation is sufficient:

      Command command = new MyCompensatingCommand();
      command.setInputPropertyX(outputPropertyP);
      return command;
 

Returns:
The compensating command associated with the command.
Throws:
CommandException - The superclass for all command exceptions. Specifically, UnavailableCompensatingCommandException is thrown if there is no compensating command associated with the command.