com.ibm.websphere.management.cmdframework.provider
Class AbstractCommandStep
- java.lang.Object
-
- org.eclipse.emf.common.command.AbstractCommand
-
- com.ibm.websphere.management.cmdframework.provider.AbstractAdminCommand
-
- com.ibm.websphere.management.cmdframework.provider.AbstractCommandStep
-
- All Implemented Interfaces:
- AdminCommand, CommandStep, org.eclipse.emf.common.command.Command
public class AbstractCommandStep extends AbstractAdminCommand implements CommandStep
The class is the base class for any command step implementation. Any specific command step 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 Modifier and Type Field and Description protected AbstractTaskCommand
taskCmd
-
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 AbstractCommandStep(AbstractTaskCommand parent, com.ibm.websphere.management.cmdframework.commanddata.CommandData commandData)
AbstractCommandStep(AbstractTaskCommand parent, com.ibm.websphere.management.cmdframework.commandmetadata.CommandMetadata metadata)
-
Method Summary
Methods Modifier and Type Method and Description void
addRow(javax.management.AttributeList rowData, int rowIndex)
Add a row to the table at the specified position.void
commandParamModified()
This method is called whenever the parameter data in the parent task command are changed.protected org.eclipse.emf.ecore.EObject
createParamEObject()
Create an EObject to store the command's parameter values.void
deleteRow(int rowIndex)
Remove a row at the specified position from the table.boolean
equals(java.lang.Object obj)
If two instance of command step have same name, we consider them eaqual.void
execute()
Step can not be executed independently, therefore this method is not supported.void
execute(CommandHistory cmdHistory)
Step can not be executed independently, therefore this method is not supported.protected void
executeStep()
Execute the current step.java.lang.Object[]
getChoices(java.lang.String paramName, int rowIndex)
Returns valid values for the specified parameter.static com.ibm.websphere.management.cmdframework.commandmetadata.CommandMetadata
getCommandMetadata(java.lang.String cmdName)
com.ibm.websphere.management.cmdframework.commanddata.CommandStepData
getCommandStepData()
A convienent method that returns more type specific value than the generic CommandData.Session
getConfigSession()
Returns user's config session.int
getNumberOfRows()
Gets the number of rows in the table.java.lang.Object
getParameter(java.lang.String parameterName, int rowIndex)
Gets the parameter value for a specified parameter and row index.int
hashcode()
Hash the command step according to the command name.protected com.ibm.websphere.management.cmdframework.commanddata.CommandData
initCommandData()
Construct proper type of command data instance.protected void
initializeRow(javax.management.AttributeList rowData, int rowIndex)
protected void
initializeStep()
Initialize the current step.boolean
isEnabled()
Tests if this command step is enabled or not.protected boolean
isLocalMode()
boolean
isRequired()
Check if step has required data missingboolean
isRequired(int rowIndex)
Check if row at the specified position has required data missingprotected boolean
isTable()
java.util.Collection
listSetParams(int rowIndex)
Lists all the parameters are set.void
resetCommandData(com.ibm.websphere.management.cmdframework.commanddata.CommandData stepData)
Reset the command data for the step.void
setParameter(java.lang.String paramName, java.lang.Object value, int rowIndex)
Sets a parameter value.void
stepModified(java.lang.String stepName)
This method is called whenever the parameter data in another task step are changed.protected void
taskCommandExecuted(boolean success, boolean executed)
This method is called when the task command completes the execution.void
validate()
Providers a default implmentation for the method.-
Methods inherited from class com.ibm.websphere.management.cmdframework.provider.AbstractAdminCommand
cleanupUploadedFiles, createParameterMetadata, generateScript, getChoices, getCmdHandler, getCmdMgrType, getCommandData, getCommandMetadata, getCommandResult, getCommandSession, getConfigService, getLocale, getName, getOrigParameterValue, getParameter, getParameterMetadata, getResult, getTargetObject, getTargetObjectChoices, getUserData, initializeParameter, initializeParameter, isAsyncCommand, isDynamicStepCommand, isParamReadonly, isPrivateParameter, listAllParameterName, listParameterName, listSetParams, redo, resetCommandMetadata, save, sendNotification, setCmdHandler, setCmdMgrType, setCommandMetadata, setCommandResult, setCommandSession, setConfigSession, setListSetParamsTable, setLocale, setOrigParameterValue, 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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.ibm.websphere.management.cmdframework.AdminCommand
createParameterMetadata, generateScript, getChoices, getCmdHandler, getCommandMetadata, getCommandResult, getLocale, getName, getOrigParameterValue, getParameter, getTargetObject, getTargetObjectChoices, isAsyncCommand, isDynamicStepCommand, isPrivateParameter, listAllParameterName, listParameterName, listSetParams, save, setCmdHandler, setConfigSession, setLocale, setOrigParameterValue, setParameter, setTargetObject
-
-
-
-
Field Detail
-
taskCmd
protected AbstractTaskCommand taskCmd
-
-
Constructor Detail
-
AbstractCommandStep
public AbstractCommandStep(AbstractTaskCommand parent, com.ibm.websphere.management.cmdframework.commandmetadata.CommandMetadata metadata)
-
AbstractCommandStep
public AbstractCommandStep(AbstractTaskCommand parent, com.ibm.websphere.management.cmdframework.commanddata.CommandData commandData) throws CommandNotFoundException
- Throws:
CommandNotFoundException
-
-
Method Detail
-
getCommandMetadata
public static com.ibm.websphere.management.cmdframework.commandmetadata.CommandMetadata getCommandMetadata(java.lang.String cmdName) throws CommandNotFoundException
- Throws:
CommandNotFoundException
-
isEnabled
public boolean isEnabled()
Description copied from interface:CommandStep
Tests if this command step is enabled or not.- Specified by:
isEnabled
in interfaceCommandStep
- Returns:
- true if this command step is enabled; false otherwise.
-
isLocalMode
protected boolean isLocalMode()
- Overrides:
isLocalMode
in classAbstractAdminCommand
-
hashcode
public final int hashcode()
Hash the command step according to the command name.
-
equals
public final boolean equals(java.lang.Object obj)
If two instance of command step have same name, we consider them eaqual. The reason is that each command step should have a unique name.- Overrides:
equals
in classjava.lang.Object
-
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.
-
getCommandStepData
public final com.ibm.websphere.management.cmdframework.commanddata.CommandStepData getCommandStepData()
A convienent method that returns more type specific value than the generic CommandData.
-
resetCommandData
public final void resetCommandData(com.ibm.websphere.management.cmdframework.commanddata.CommandData stepData)
Reset the command data for the step.- Overrides:
resetCommandData
in classAbstractAdminCommand
- Parameters:
stepData
- the new command data for the step.
-
execute
public final void execute(CommandHistory cmdHistory)
Step can not be executed independently, therefore this method is not supported.- Specified by:
execute
in interfaceAdminCommand
- Overrides:
execute
in classAbstractAdminCommand
- Parameters:
cmdHistory
- an implementation of command history
-
execute
public final void execute()
Step can not be executed independently, therefore this method is not supported.- Specified by:
execute
in interfaceorg.eclipse.emf.common.command.Command
- Specified by:
execute
in classAbstractAdminCommand
-
listSetParams
public java.util.Collection listSetParams(int rowIndex) throws java.lang.IndexOutOfBoundsException
Description copied from interface:CommandStep
Lists all the parameters are set.- Specified by:
listSetParams
in interfaceCommandStep
- Overrides:
listSetParams
in classAbstractAdminCommand
- Parameters:
rowIndex
- the row index in the table. Ignored if the command step parameter data is not a table.- Returns:
- a collection of parameter names whose value are set.
- Throws:
java.lang.IndexOutOfBoundsException
-
getParameter
public java.lang.Object getParameter(java.lang.String parameterName, int rowIndex) throws InvalidParameterNameException, java.lang.IndexOutOfBoundsException
Description copied from interface:CommandStep
Gets the parameter value for a specified parameter and row index.- Specified by:
getParameter
in interfaceCommandStep
- Overrides:
getParameter
in classAbstractAdminCommand
- Parameters:
parameterName
- the name of a paramterrowIndex
- the row index in the table. Ignored if the command step parameter data is not a table.- Returns:
- the parameter value for the specified parameter at the specified row index.
- Throws:
InvalidParameterNameException
java.lang.IndexOutOfBoundsException
-
setParameter
public void setParameter(java.lang.String paramName, java.lang.Object value, int rowIndex) throws InvalidParameterValueException, InvalidParameterNameException, java.lang.IndexOutOfBoundsException
Description copied from interface:CommandStep
Sets a parameter value.- Specified by:
setParameter
in interfaceCommandStep
- Overrides:
setParameter
in classAbstractAdminCommand
- Parameters:
paramName
- the name of a parameter.value
- the value of a parameter.rowIndex
- the row index in the table. Ignored if the command step parameter data is not a table.- Throws:
InvalidParameterValueException
InvalidParameterNameException
java.lang.IndexOutOfBoundsException
-
getNumberOfRows
public int getNumberOfRows()
Description copied from interface:CommandStep
Gets the number of rows in the table.- Specified by:
getNumberOfRows
in interfaceCommandStep
-
initializeRow
protected void initializeRow(javax.management.AttributeList rowData, int rowIndex) throws InvalidParameterValueException, java.lang.IndexOutOfBoundsException
- Throws:
InvalidParameterValueException
java.lang.IndexOutOfBoundsException
-
addRow
public void addRow(javax.management.AttributeList rowData, int rowIndex) throws InvalidParameterValueException, java.lang.IndexOutOfBoundsException
Description copied from interface:CommandStep
Add a row to the table at the specified position.- Specified by:
addRow
in interfaceCommandStep
- Parameters:
rowData
- the parameter data in a row. The attribute name is a parameter name and the attribute value is the value for the parameter.rowIndex
- the row index in the table. Ignored if the command step parameter data is not a table.- Throws:
InvalidParameterValueException
java.lang.IndexOutOfBoundsException
-
deleteRow
public void deleteRow(int rowIndex) throws java.lang.UnsupportedOperationException
Description copied from interface:CommandStep
Remove a row at the specified position from the table.- Specified by:
deleteRow
in interfaceCommandStep
- Parameters:
rowIndex
- the row index in the table.- Throws:
java.lang.UnsupportedOperationException
- if the command step parameter data is not a table.
-
isTable
protected final boolean isTable()
- Overrides:
isTable
in classAbstractAdminCommand
-
createParamEObject
protected final org.eclipse.emf.ecore.EObject createParamEObject() throws CommandNotFoundException
Description copied from class:AbstractAdminCommand
Create an EObject to store the command's parameter values.- Overrides:
createParamEObject
in classAbstractAdminCommand
- Returns:
- an EObject instance to store the command's parameter values.
- Throws:
CommandNotFoundException
-
stepModified
public void stepModified(java.lang.String stepName) throws CommandException
This method is called whenever the parameter data in another task step are changed. The default implementation of this methods is a no-op. Subclass may optionally implement additional logic to respond to the changes in other steps. Command provider may use this mechanism to implement the dependencies among steps.- Parameters:
stepName
- the step name.- Throws:
CommandException
- if not able to change task step by subclass.
-
commandParamModified
public void commandParamModified()
This method is called whenever the parameter data in the parent task command are changed. The default implementation of this method is a no-op. Subclass may optionally implement additional logic to respond to the changes in parent task command. Command provider may use this mechanism to implement the dependencies between task command and this command step.
-
validate
public void validate() throws CommandValidationException
Description copied from class:AbstractAdminCommand
Providers a default implmentation for the method. The default implementation checks if all the required parameters are specified, also it checks if the types of specified parameter values matches up the type of the parameter data defined in metadata. Extended class may override this method to validate the command parameter further.- Specified by:
validate
in interfaceAdminCommand
- Overrides:
validate
in classAbstractAdminCommand
- Throws:
CommandValidationException
- if there is any invalid command parameter.
-
taskCommandExecuted
protected void taskCommandExecuted(boolean success, boolean executed)
This method is called when the task command completes the execution. The default implementation of this method is a no-op. Subclass may optionally override this method to clean up the data structure or resources. This method can also used to undo some of the side effect this step caused in case the task command execution failed.- Parameters:
success
- true if the task command executed successfully, false otherwise.executed
- true if this step is ever executed, false otherwise.
-
executeStep
protected void executeStep()
Execute the current step. The default implementation of this method is a no-op. Subclass may optionally override this method to implement the execution logic for the step.
-
initializeStep
protected void initializeStep() throws CommandException
Initialize the current step.This method is called when this step is returned to command user first time.
- Throws:
CommandException
-
isRequired
public boolean isRequired()
Description copied from interface:CommandStep
Check if step has required data missing- Specified by:
isRequired
in interfaceCommandStep
- Returns:
- true if this command step has required data missing; otherwise false.
-
getConfigSession
public Session getConfigSession()
Description copied from interface:AdminCommand
Returns user's config session. It returns null if the config session is never set.- Specified by:
getConfigSession
in interfaceAdminCommand
- Overrides:
getConfigSession
in classAbstractAdminCommand
- Returns:
- user's config session.
-
isRequired
public boolean isRequired(int rowIndex)
Description copied from interface:CommandStep
Check if row at the specified position has required data missing- Specified by:
isRequired
in interfaceCommandStep
- Parameters:
rowIndex
- the row index in the table.- Returns:
- true if this row has required data missing; otherwise false.
-
getChoices
public java.lang.Object[] getChoices(java.lang.String paramName, int rowIndex)
Description copied from interface:CommandStep
Returns valid values for the specified parameter. Implementation of this method is optional. If command provider does not implement this method, then this method returns null.- Specified by:
getChoices
in interfaceCommandStep
- Parameters:
paramName
- the parameter name.rowIndex
- the row index in the table.- Returns:
- an array of valid values for the specified parameter.
-
-