Develop > Business logic layer > Name-value pair command framework > Customize existing task commands


Replace business logic of an existing task command

To replace the business logic of an existing task command, create a new implementation class for the task command. This new implementation class must extend from the existing task command but it should not implement the existing interface. Additionally, in the new implementation class, do not call the performExecute method of the superclass.

While extending from the exact command that you are replacing may seem counterintuitive, the reason for taking this approach is related to support for future versions of WebSphere Commerce. This approach shields the code from changes that may be made to command interfaces in future versions of WebSphere Commerce.

As an example, suppose you wanted to replace the business logic of the OrderNotifyCmdImpl task command. In this case, you would create a new task command called CustomizedOrderNotifyCmdImpl. This command extends OrderNotifyCmdImpl. In the new CustomizedOrderNotifyCmdImpl, you create the new business logic, but do not call the performExecute method from the superclass. If a future version of WebSphere Commerce then introduces a new method, called newMethod in the interface, the corresponding version of the OrderNotifyCmdImpl command will include a default implementation of the newMethod method. Then, since the new command extends from OrderNotifyCmdImpl, the compiler will find the default implementation of this new method in the OrderNotifyCmdImpl command and the new command is shielded from the interface change.


Related tasks

Customize existing task commands


+

Search Tips   |   Advanced Search