+

Search Tips   |   Advanced Search

 

Facilities for implementing commands

 

Commands are implemented by extending the class TargetableCommandImpl, which implements the TargetableCommand interface. The TargetableCommandImpl class is an abstract class that provides some implementations for some of the methods in the TargetableCommand interface (for example, setting return values) and declares additional methods that the application itself must implement (for example, how to execute the command). You implement your command interface by writing a class that extends the TargetableCommandImpl class and implements your command interface. This class contains the code for the methods in your interface, the methods inherited from extended interfaces (the TargetableCommand and CompensableCommand interfaces), and the required (abstract) methods in the TargetableCommandImpl class. You can also override the default implementations of other methods provided in the TargetableCommandImpl class. The following example shows the structure of an implementation class for an interface:

... import java.lang.reflect.*; import com.ibm.websphere.command.*; public class MyCommandImpl extends TargetableCommandImpl implements MyCommand
{ // Set instance variables here ... // Implement methods in the MyCommand interface ... // Implement methods in the CompensableCommand interface ...
// Implement abstract methods in the TargetableCommandImpl class ... }



 

Related tasks


Writing command interfaces

 

Related Reference


TargetableCommand interface