Example: Implementing methods from the Command interface

The Command interface declares two methods, isReadyToCallExecute and reset, that the application programmer must implement.

Methods from the Command interface in the ModifyCheckingAccountCmdImpl class

The following code example shows the implementations for the ModifyCheckingAccountCmd command. The implementation of the isReadyToCallExecute method ensures that the checkingAccount variable is set. The reset method sets all of the variables back to starting values.

...
public class ModifyCheckingAccountCmdImpl extends TargetableCommandImpl
implements ModifyCheckingAccountCmd
{
...
// Methods from the Command interface
public boolean isReadyToCallExecute() {
if (checkingAccount != null)
return true;
else
return false;
}
public void reset() {
amount = 0;
balance = 0;
oldBalance = 0;
checkingAccount = null;
targetPolicy = new TargetPolicyDefault();
}
...
}



Related tasks
Implementing command interfaces
Reference topic    

Terms of Use | Feedback

Last updated: Feb 19, 2011 5:25:36 AM CST
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=v610web&product=was-nd-mp&topic=rcmd_implmethcmdint
File name: rcmd_implmethcmdint.html