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 Reference topic    

Terms and conditions for information centers | Feedback

Last updatedLast updated: Aug 31, 2013 2:56:59 AM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=pix&product=was-nd-dist&topic=rcmd_implmethcmdint
File name: rcmd_implmethcmdint.html