com.ibm.websphere.management.cmdframework

Interface TaskCommand

  • All Superinterfaces:
    AdminCommand, org.eclipse.emf.common.command.Command
    All Known Implementing Classes:
    AbstractTaskCommand


    public interface TaskCommand
    extends AdminCommand
    Defines the interface for a task oriented admin command. A TaskCommand can have zero or multiple parameters like any AdminCommand. Besides it can also have one or multiple command steps. TaskCommand can be used to implement complex admin commands that involves multiple steps. For Instance, Integrated Solutions Console may use task command to implement its wizards.

    User may execute a TaskCommand in either batch mode or interactive mode. In batch mode, user specifies the parameter data on task command and command steps then invokes execute the task command as shown below.
              CommandMgr cmdMgr = CommandMgr.getCommandMgr();
              TaskCommand taskCmd = (TaskCommand) cmdMgr.createCommand(myTaskCmdName);
              taskCmd.setParameter("param1", v1);
              taskCmd.setParameter("param2", v2);
                   :
                   :
                   :
              CommandStep step1 = taskCmd.getCommandStep("stepName1");
              step1.setParameter("step1Param1", v1);
              step1.setParameter("step1Param2", v2);
                    :
                    :
              CommandStep step2 = taskCmd.getCommandStep("stepName2");
              step2.setParameter("step2Param1", v1);
              step2.setParameter("step2Param2", v2);
                    :
                    :
              taskCmd.execute();
    
     
    In interactive mode, users can navigate enabled command steps back and forth interactively. Three methods are provided for user to traverse command steps either sequentially or randomly: previousStep, nextStep and gotoStep methods. TaskCommand keeps an internal cursor and the cursor moves whenever user navigates through command steps by calling one of the above methods. The cursor position always lies between the enabled step that would be returned by a call to previous() and the enabled step that would be returned by a call to next(). Initially, the cursor position is before the first enabled step. After one of the methods mentioned above is called, the cursor is moved after the returned step. The code snippet below shows how to use task command in the interactive mode.
              CommandMgr cmdMgr = CommandMgr.getCommandMgr();
              TaskCommand taskCmd = (TaskCommand) cmdMgr.createCommand(myTaskCmdName);
              taskCmd.setParameter("param1", v1);
              taskCmd.setParameter("param2", v2);
                   :
                   :
                   :
              // get the first enabled step.
              CommandStep step1 = taskCmd.next();
              step1.setParameter("step1Param1", v1);
              step1.setParameter("step1Param2", v2);
                    :
                    :
              // go to the next enabled step.
              if (taskCmd.hasNextStep()) {
                  CommandStep step2 = taskCmd.next();
                  step2.setParameter("step2Param1", v1);
                  step2.setParameter("step2Param2", v2);
                    :
                    :
              }
    
              // go to the previous enabled step.
              if (taskCmd.hasPreviousStep()) {
                  CommandStep step3 = taskCmd.previous();
                  step3.setParameter("step3Param1", v1);
                  step3.setParameter("step3Param2", v2);
                    :
                    :
              }
    
              // directly go to an enabled step.
              CommandStep step4 = taskCmd.gotoStep("aStepName");
              step4.setParameter("step4Param1", v1);
              step4.setParameter("step4Param2", v2);
                    :
                    :
              taskCmd.execute();
    
     
    Since the TaskCommand keeps an internal cursor when a user navigates through steps, the user should only modify the step returned from the last call that moves the cursor. The code snippet shown below is not valid.
                   :
                   :
              // get the first enabled step.
              CommandStep step1 = taskCmd.next();
              step1.setParameter("step1Param1", v1);
              step1.setParameter("step1Param2", v2);
                    :
                    :
              // go to the next enabled step.
              if (taskCmd.hasNextStep()) {
                  CommandStep step2 = taskCmd.next();
                  step2.setParameter("step2Param1", v1);
                  step2.setParameter("step2Param2", v2);
                    :
                    :
              }
              // line below is not valid.
              step1.setParameter("step1Param1", v5);
     

    • Method Detail

      • nextStep

        CommandStep nextStep()
                             throws java.util.NoSuchElementException
        Gets the next enabled command step. Returns the first enabled step if this method is called first time.
        Returns:
        the next enabled command step.
        Throws:
        java.util.NoSuchElementException - if there is no enabled step after the cursor.
      • previousStep

        CommandStep previousStep()
                                 throws java.util.NoSuchElementException
        Gets the previous enabled step in the task command.
        Returns:
        the previous enabled step in the task command.
        Throws:
        java.util.NoSuchElementException - if there is no enabled step before the cursor.
      • hasNextStep

        boolean hasNextStep()
        Tests if there is an enabled step after the cursor.
        Returns:
        true if there is an enabled step after the cursor.
      • hasPreviousStep

        boolean hasPreviousStep()
        Tests if there is an enabled step before the cursor.
        Returns:
        true if there is an enabled step before the cursor.
      • gotoStep

        CommandStep gotoStep(java.lang.String stepName)
                             throws java.util.NoSuchElementException
        Goes to the specified step. This method puts the cursor after the step if the call succeeds; the cusor is not moved if the call fails.
        Parameters:
        stepName - the step name
        Returns:
        the specified step if the step is found and enabled.
        Throws:
        java.util.NoSuchElementException - if the step is not found or not enabled.
      • listCommandSteps

        java.lang.String[] listCommandSteps()
        Lists the command step names contained in this task command including the disabled command steps.
        Returns:
        the names of command steps defined in this command.
      • getCommandStep

        CommandStep getCommandStep(java.lang.String stepName)
                                   throws CommandNotFoundException
        Gets the command step of the specified command step name. Unlike the gotoStep method, this method does not change the cursor position. Typically this method is called when the task command is executed in batch mode.
        Parameters:
        stepName - the command step name
        Returns:
        the command step of the specified command step name.
        Throws:
        CommandNotFoundException
      • getTaskCommandResult

        TaskCommandResult getTaskCommandResult()
        Gets the task command result.
      • processTaskParameters

        void processTaskParameters()
                                   throws CommandException
        Process task command parameters
        Throws:
        CommandException - if not able to process task parameters.
IBM WebSphere Application ServerTM
Release 8.5