com.ibm.websphere.management.cmdframework
Interface TaskCommand
All Superinterfaces:
AdminCommand, org.eclipse.emf.common.command.Command
All known implementing classes:
- public interface TaskCommand
- extends AdminCommand
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 |
---|---|
getCommandStep(java.lang.String stepName)
Gets the command step of the specified command step name.
|
|
getTaskCommandResult()
Gets the task command result.
|
|
gotoStep(java.lang.String stepName)
Goes to the specified step.
|
|
|
hasNextStep()
Tests if there is an enabled step after the cursor.
|
|
hasPreviousStep()
Tests if there is an enabled step before the cursor.
|
|
listCommandSteps()
Lists the command step names contained in this task command including
the disabled command steps.
|
nextStep()
Gets the next enabled command step.
|
|
previousStep()
Gets the previous enabled step in the task command.
|
|
|
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
- 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:
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.