com.ibm.websphere.management.cmdframework.provider
Class AbstractTaskCommand
- java.lang.Object
-
- org.eclipse.emf.common.command.AbstractCommand
-
- com.ibm.websphere.management.cmdframework.provider.AbstractAdminCommand
-
- com.ibm.websphere.management.cmdframework.provider.AbstractTaskCommand
-
- All Implemented Interfaces:
- AdminCommand, TaskCommand, org.eclipse.emf.common.command.Command
public abstract class AbstractTaskCommand extends AbstractAdminCommand implements TaskCommand
The class is the base class for any task command implementation. Any specific task command implementation should derive from this class and only override the methods that javadoc recommends to override.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.ibm.websphere.management.cmdframework.provider.AbstractAdminCommand
AbstractAdminCommand.CmdNotificationListener
-
-
Field Summary
-
Fields inherited from class com.ibm.websphere.management.cmdframework.provider.AbstractAdminCommand
ASYNC_CUSTOM_TAG, asyncCmdSession, cmdMgrType, cnh, DYNAMIC_CUSTOM_TAG, listSetParamsTable, PRIVATE_CUSTOM_TAG
-
-
Constructor Summary
Constructors Constructor and Description AbstractTaskCommand(com.ibm.websphere.management.cmdframework.commanddata.CommandData commandData)
AbstractTaskCommand(com.ibm.websphere.management.cmdframework.commandmetadata.TaskCommandMetadata inMetadata)
-
Method Summary
Methods Modifier and Type Method and Description protected void
addNewStep(com.ibm.websphere.management.cmdframework.commandmetadata.TaskCommandMetadata metadata, com.ibm.websphere.management.cmdframework.commanddata.CommandStepData stepData, int i)
void
addStep(AbstractCommandStep step, int index)
add an additional step for the task.protected void
afterStepsExecuted()
This method is called after the steps are executed.protected void
beforeStepsExecuted()
This method is called before the steps are executed.void
commandParamsModified()
This method is called before the user starts to navigate through steps.protected void
contructSteps()
void
execute()
Implements the execution flow for a task command.CommandStep
getCommandStep(java.lang.String stepName)
Gets the command step of the specified command step name.CommandStep
getCurrentStep(int operation)
CommandStep
getCurrentStep(int operation, java.lang.String stepName)
int
getCurrentStepIndex()
com.ibm.websphere.management.cmdframework.commanddata.TaskCommandData
getTaskCommandData()
com.ibm.websphere.management.cmdframework.commandmetadata.TaskCommandMetadata
getTaskCommandMetadata()
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.protected com.ibm.websphere.management.cmdframework.commanddata.CommandData
initCommandData()
Construct proper type of command data instance.void
listAllStepParamsData()
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()
This method is called to process task parameters.void
resetCommandData(com.ibm.websphere.management.cmdframework.commanddata.CommandData cmdData)
Reset the command data.void
setCurrentStep(AbstractCommandStep newCurrentStep)
void
setCurrentStepIndex(int index)
protected java.lang.String
showArrayContents(java.lang.Object[] array)
protected java.lang.String
showListContents(java.util.List list)
protected void
stepModified(java.lang.String stepName)
This method is called whenever the user navigates away from the specified step.protected void
taskCommandExecuted(boolean success)
This method is called after the task command is executed.void
validate()
This provides a basic implementation for command parameter validation.-
Methods inherited from class com.ibm.websphere.management.cmdframework.provider.AbstractAdminCommand
cleanupUploadedFiles, createParamEObject, createParameterMetadata, execute, generateScript, getChoices, getCmdHandler, getCmdMgrType, getCommandData, getCommandMetadata, getCommandMetadata, getCommandResult, getCommandSession, getConfigService, getConfigSession, getLocale, getName, getOrigParameterValue, getParameter, getParameter, getParameterMetadata, getResult, getTargetObject, getTargetObjectChoices, getUserData, initializeParameter, initializeParameter, isAsyncCommand, isDynamicStepCommand, isLocalMode, isParamReadonly, isPrivateParameter, isTable, listAllParameterName, listParameterName, listSetParams, listSetParams, redo, resetCommandMetadata, save, sendNotification, setCmdHandler, setCmdMgrType, setCommandMetadata, setCommandResult, setCommandSession, setConfigSession, setListSetParamsTable, setLocale, setOrigParameterValue, setParameter, setParameter, setTargetObject, setupListener
-
Methods inherited from class org.eclipse.emf.common.command.AbstractCommand
canExecute, canUndo, chain, dispose, getAffectedObjects, getDescription, getLabel, prepare, setDescription, setLabel, toString, undo
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
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
-
-
-
-
Constructor Detail
-
AbstractTaskCommand
public AbstractTaskCommand(com.ibm.websphere.management.cmdframework.commandmetadata.TaskCommandMetadata inMetadata) throws CommandNotFoundException
- Throws:
CommandNotFoundException
-
AbstractTaskCommand
public AbstractTaskCommand(com.ibm.websphere.management.cmdframework.commanddata.CommandData commandData) throws CommandNotFoundException, CommandLoadException
-
-
Method Detail
-
contructSteps
protected void contructSteps() throws CommandNotFoundException
- Throws:
CommandNotFoundException
-
initCommandData
protected com.ibm.websphere.management.cmdframework.commanddata.CommandData initCommandData()
Description copied from class:AbstractAdminCommand
Construct proper type of command data instance.- Overrides:
initCommandData
in classAbstractAdminCommand
- Returns:
- newly created command data instance.
-
getCurrentStep
public CommandStep getCurrentStep(int operation)
-
getCurrentStep
public CommandStep getCurrentStep(int operation, java.lang.String stepName)
-
setCurrentStep
public void setCurrentStep(AbstractCommandStep newCurrentStep)
-
getCurrentStepIndex
public int getCurrentStepIndex()
-
setCurrentStepIndex
public void setCurrentStepIndex(int index)
-
listCommandSteps
public java.lang.String[] listCommandSteps()
Description copied from interface:TaskCommand
Lists the command step names contained in this task command including the disabled command steps.- Specified by:
listCommandSteps
in interfaceTaskCommand
- Returns:
- the names of command steps defined in this command.
-
nextStep
public final CommandStep nextStep() throws java.util.NoSuchElementException
Description copied from interface:TaskCommand
Gets the next enabled command step. Returns the first enabled step if this method is called first time.- Specified by:
nextStep
in interfaceTaskCommand
- Returns:
- the next enabled command step.
- Throws:
java.util.NoSuchElementException
- if there is no enabled step after the cursor.
-
previousStep
public final CommandStep previousStep() throws java.util.NoSuchElementException
Description copied from interface:TaskCommand
Gets the previous enabled step in the task command.- Specified by:
previousStep
in interfaceTaskCommand
- Returns:
- the previous enabled step in the task command.
- Throws:
java.util.NoSuchElementException
- if there is no enabled step before the cursor.
-
hasNextStep
public final boolean hasNextStep()
Description copied from interface:TaskCommand
Tests if there is an enabled step after the cursor.- Specified by:
hasNextStep
in interfaceTaskCommand
- Returns:
- true if there is an enabled step after the cursor.
-
hasPreviousStep
public final boolean hasPreviousStep()
Description copied from interface:TaskCommand
Tests if there is an enabled step before the cursor.- Specified by:
hasPreviousStep
in interfaceTaskCommand
- Returns:
- true if there is an enabled step before the cursor.
-
gotoStep
public final CommandStep gotoStep(java.lang.String stepName) throws java.util.NoSuchElementException
Description copied from interface:TaskCommand
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.- Specified by:
gotoStep
in interfaceTaskCommand
- 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.
-
getCommandStep
public CommandStep getCommandStep(java.lang.String stepName) throws CommandNotFoundException
Description copied from interface:TaskCommand
Gets the command step of the specified command step name. Unlike thegotoStep
method, this method does not change the cursor position. Typically this method is called when the task command is executed in batch mode.- Specified by:
getCommandStep
in interfaceTaskCommand
- Parameters:
stepName
- the command step name- Returns:
- the command step of the specified command step name.
- Throws:
CommandNotFoundException
-
getTaskCommandData
public final com.ibm.websphere.management.cmdframework.commanddata.TaskCommandData getTaskCommandData()
-
getTaskCommandMetadata
public final com.ibm.websphere.management.cmdframework.commandmetadata.TaskCommandMetadata getTaskCommandMetadata()
-
addStep
public void addStep(AbstractCommandStep step, int index)
add an additional step for the task.- Parameters:
step
- - the step instance.index
- - the position of added step in the step list. If index is out of range, then the step will be added at the end.
-
resetCommandData
public void resetCommandData(com.ibm.websphere.management.cmdframework.commanddata.CommandData cmdData)
Reset the command data. Subclass may override this method to put more logic in, but the overriding implementation must call the base implementation first.- Overrides:
resetCommandData
in classAbstractAdminCommand
- Parameters:
cmdData
- the new command data.
-
addNewStep
protected void addNewStep(com.ibm.websphere.management.cmdframework.commandmetadata.TaskCommandMetadata metadata, com.ibm.websphere.management.cmdframework.commanddata.CommandStepData stepData, int i)
-
validate
public void validate() throws CommandValidationException
This provides a basic implementation for command parameter validation. Basically it validates that the parameter values match up the paramter type and all the required parameters are specified. Subclass may override this method to provide more validation, but it is strongly recommended that the overriding implementation calls the base implementation first.- Specified by:
validate
in interfaceAdminCommand
- Overrides:
validate
in classAbstractAdminCommand
- Throws:
CommandValidationException
- if there is any invalid command parameter.
-
processTaskParameters
public void processTaskParameters()
This method is called to process task parameters. Command providers which override this processTaskParameters must invoke super.processTaskParameters first and check the command result for any error. The subclass would simply return in the event that the command result indicates that an error occurred. This gives AbstractTaskCommand the chance to perform any preprocessing that might be necessary.- Specified by:
processTaskParameters
in interfaceTaskCommand
-
beforeStepsExecuted
protected void beforeStepsExecuted()
This method is called before the steps are executed. The default implementation is a no-op. Subclass may optionally override this method to do something before steps are executed.
-
afterStepsExecuted
protected void afterStepsExecuted()
This method is called after the steps are executed. The default implementation is a no-op. Subclass may optionally override this method to do something after steps are executed.
-
taskCommandExecuted
protected void taskCommandExecuted(boolean success)
This method is called after the task command is executed. The default implementation is a no-op. Subclass may optionally override this method to clean up data structure or release resources after the task command is executed.- Parameters:
success
- true if the command is executed successfully; false otherwise.
-
showArrayContents
protected java.lang.String showArrayContents(java.lang.Object[] array)
-
showListContents
protected java.lang.String showListContents(java.util.List list)
-
stepModified
protected void stepModified(java.lang.String stepName)
This method is called whenever the user navigates away from the specified step. The default implementation notifies all the steps except the specified step that the specified step is modified. Subclass may optionally override this method to response to the modification further, however it is strongly recommended that the subclass implementation calls the base implementation first.- Parameters:
stepName
- the name of the step.
-
commandParamsModified
public void commandParamsModified()
This method is called before the user starts to navigate through steps. The default implementation notifies all the steps dified. Subclass may optionally override this method to response to the modification further, however it is strongly recommended that the subclass implementation calls the base implementation first.
-
execute
public void execute()
Implements the execution flow for a task command. This method is final. In other words, subclass should not override this method. The reason is that command framework controls the general control flow. Subclasses may override more specific methods to implement the task command specific semantics and behavior.- Specified by:
execute
in interfaceorg.eclipse.emf.common.command.Command
- Specified by:
execute
in classAbstractAdminCommand
-
getTaskCommandResult
public TaskCommandResult getTaskCommandResult()
Description copied from interface:TaskCommand
Gets the task command result.- Specified by:
getTaskCommandResult
in interfaceTaskCommand
-
listAllStepParamsData
public void listAllStepParamsData()
-
-