Implementing command interfaces
The command package provides a class, TargetableCommandImpl, that implements all of the methods in the TargetableCommand interface except the performExecute method. It also implements the execute method from the Command interface.
Overview
Procedure
- To implement an application command interface, write a class that extends the TargetableCommandImpl class and implements your command interface. The structure of the ModifyCheckingAccountCmdImpl class is as follows:
public class ModifyCheckingAccountCmdImpl extends TargetableCommandImpl implements ModifyCheckingAccountCmd { // Variables ... // Methods ... }
- The class must declare any variables and implement the following methods:
- Any methods you defined in your command interface.
- The isReadyToCallExecute and reset methods from the Command interface.
- The performExecute method from the TargetableCommand interface.
- The getCompensatingCommand method from the CompensableCommand interface, if your command is compensable. You must also implement the compensating command.
You can also override the nonfinal implementations provided in the TargetableCommandImpl class. The most likely candidate for reimplementation is the setOutputProperties method, since the default implementation does not save final, transient, or static fields.
Instance and class variables
Command-specific methods
Example: Implementing methods from the TargetableCommand interface
Setting and determining targets
Example: Implementing methods from the Command interface
Example: Implementing methods from the Compensable interface