Example: Using a custom target policy

The ModifyCheckingAccountImpl class provides two command constructors. One of them implicitly uses the default target policy; the other takes a target policy object as an argument, which enables you to use a custom target policy.

Custom target policy example

The following example uses the second constructor, passing a null target and a custom target policy, so that the custom policy is used to determine the target. After the command is executed, the code uses the reset method to return the target policy to the default.

{
...
CheckingAccount checkingAccount
....
try {
CustomTargetPolicy customPolicy = new CustomTargetPolicy();
ModifyCheckingAccountCmd cmd =
new ModifyCheckingAccountCmdImpl(null, 1000, customPolicy);
cmd.setCheckingAccount(checkingAccount);
cmd.execute();
cmd.reset();
}
catch (Exception e) {
System.out.println(e.getMessage());
}
}



Related concepts
Targets and target policies
Related tasks
Using a command
Reference topic Reference topic    

Terms and conditions for information centers | Feedback

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