|
IBM WebSphere Application ServerTM Release 8 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface TaskCommand
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 | |
---|---|
CommandStep |
getCommandStep(java.lang.String stepName)
Gets the command step of the specified command step name. |
TaskCommandResult |
getTaskCommandResult()
Gets the task command result. |
CommandStep |
gotoStep(java.lang.String stepName)
Goes to the specified step. |
boolean |
hasNextStep()
Tests if there is an enabled step after the cursor. |
boolean |
hasPreviousStep()
Tests if there is an enabled step before the cursor. |
java.lang.String[] |
listCommandSteps()
Lists the command step names contained in this task command including the disabled command steps. |
CommandStep |
nextStep()
Gets the next enabled command step. |
CommandStep |
previousStep()
Gets the previous enabled step in the task command. |
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 |
---|
CommandStep nextStep() throws java.util.NoSuchElementException
java.util.NoSuchElementException
- if there is no enabled step after the cursor.CommandStep previousStep() throws java.util.NoSuchElementException
java.util.NoSuchElementException
- if there is no enabled step before the cursor.boolean hasNextStep()
boolean hasPreviousStep()
CommandStep gotoStep(java.lang.String stepName) throws java.util.NoSuchElementException
stepName
- the step name
java.util.NoSuchElementException
- if the step is not found or not enabled.java.lang.String[] listCommandSteps()
CommandStep getCommandStep(java.lang.String stepName) throws CommandNotFoundException
gotoStep
method, this method does not change
the cursor position. Typically this method is called when the task command
is executed in batch mode.
stepName
- the command step name
CommandNotFoundException
TaskCommandResult getTaskCommandResult()
void processTaskParameters() throws CommandException
CommandException
- if not able to process task parameters.
|
IBM WebSphere Application ServerTM Release 8 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |