com.ibm.websphere.management.cmdframework

Interface TaskCommand

All Superinterfaces:
AdminCommand, org.eclipse.emf.common.command.Command
All known implementing classes:
AbstractTaskCommand

  1. public interface TaskCommand
  2. 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 Summary

Modifier and Type Method and Description
  1. CommandStep
getCommandStep(java.lang.String stepName)
Gets the command step of the specified command step name.
  1. TaskCommandResult
getTaskCommandResult()
Gets the task command result.
  1. CommandStep
gotoStep(java.lang.String stepName)
Goes to the specified step.
  1. boolean
hasNextStep()
Tests if there is an enabled step after the cursor.
  1. boolean
hasPreviousStep()
Tests if there is an enabled step before the cursor.
  1. java.lang.String[]
listCommandSteps()
Lists the command step names contained in this task command including the disabled command steps.
  1. CommandStep
nextStep()
Gets the next enabled command step.
  1. CommandStep
previousStep()
Gets the previous enabled step in the task command.
  1. void
processTaskParameters()
Process task command parameters
Methods inherited from interface com.ibm.websphere.management.cmdframework.AdminCommand
createParameterMetadata, execute, generateScript, getChoices, getCmdHandler, getCommandMetadata, getCommandResult, getConfigSession, getLocale, getName, getOrigParameterValue, getParameter, getTargetObject, getTargetObjectChoices, isAsyncCommand, isDynamicStepCommand, isPrivateParameter, listAllParameterName, listParameterName, listSetParams, save, setCmdHandler, setConfigSession, setLocale, setOrigParameterValue, setParameter, setTargetObject, validate
Methods inherited from interface org.eclipse.emf.common.command.Command
canExecute, canUndo, chain, dispose, execute, getAffectedObjects, getDescription, getLabel, getResult, redo, undo

Method Detail

nextStep

  1. CommandStep nextStep()
  2. 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

  1. CommandStep previousStep()
  2. 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

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

hasPreviousStep

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

gotoStep

  1. CommandStep gotoStep(java.lang.String stepName)
  2. 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

  1. 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

  1. CommandStep getCommandStep(java.lang.String stepName)
  2. 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:

getTaskCommandResult

  1. TaskCommandResult getTaskCommandResult( )
Gets the task command result.

processTaskParameters

  1. void processTaskParameters()
  2. throws CommandException
Process task command parameters
Throws:
CommandException - if not able to process task parameters.