Excluding Default Commands

If you wish to prevent certain Command classes from being instantiated, the framework provides a simple mechanism for doing so. In class CommandLaunchTask, you can see that a protected method has been implememented for each and every default Command class available. All you have to do override these methods in your derived class and do nothing.

Example 11.2. Encapsulation of command instance creation

class CommandLaunchTask extends AbstractLaunchTask
{
        
  {...}
        
  final public int run() throws Exception
  {
    doNewDocumentCommand();
                
    doOpenCommand();
                
    doCloneDocumentCommand();
                
    doCloseCommand();
                
    doCloseAllCommand();
                
    {...}