org.rhq.enterprise.communications.command.impl.generic
Class GenericCommand

java.lang.Object
  extended by org.rhq.enterprise.communications.command.AbstractCommand
      extended by org.rhq.enterprise.communications.command.impl.generic.GenericCommand
All Implemented Interfaces:
Serializable, Command

public class GenericCommand
extends AbstractCommand

Defines a custom command in which the command metadata (in other words, command type and parameter definitions) are mutable. That is, there are setters defined in this class that allow for command type and parameter definitions to be modified.

Of course, a custom command is worthless unless there is a command service on the server side that can process the command. That is to say, the command type and parameter definitions must be acceptable to the command service where the command is issued.

It is generally not a good thing to allow users of commands to be able to modify command types and parameter definitions as this could make the command inoperable (which is why this capability does not exist in the base superclass}. However, this capability may be needed for specialized clients.

Note that modifications to a custom command have no effect on previous executions of the command. While this may seem obvious, a less obvious effect is that a command whose AbstractCommand.isCommandInResponse() was true at the time of execution will be stored in the resulting CommandResponse - changing that flag to false after the fact will not alter that previous command response.

Author:
John Mazzitelli
See Also:
Serialized Form

Constructor Summary
GenericCommand()
           
GenericCommand(Command commandToTransform)
           
GenericCommand(CommandType commandType, ParameterDefinition[] paramDefs)
          Specialized constructor for GenericCommand that allows the instantiator to dynamically define this generic commands metadata at runtime.
GenericCommand(Map<String,Object> commandParameters)
           
 
Method Summary
protected  CommandType buildCommandType()
          Builds the command type of this command.
protected  ParameterDefinition[] buildParameterDefinitions()
          Builds the set of parameter definitions that this command will use.
 void setCommandType(CommandType newCommandType)
          Allows the caller to modify this custom command's type.
 void setParameterDefinitions(ParameterDefinition[] newParameterDefinitions)
          Allows the caller to modify this custom command's parameter definitions.
 
Methods inherited from class org.rhq.enterprise.communications.command.AbstractCommand
allowAnyParameter, checkParameterValidity, convertParameters, getCommandType, getConfiguration, getParameterDefinition, getParameterDefinitions, getParameterValue, getParameterValues, getParameterValuesInternalMap, hasParameterValue, initializeMetadata, isCommandInResponse, removeParameterValue, removeParameterValues, setCommandInResponse, setParameterValue, setParameterValuesInternalMap, toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GenericCommand

public GenericCommand()
               throws IllegalArgumentException,
                      InvalidParameterDefinitionException
Throws:
IllegalArgumentException
InvalidParameterDefinitionException
See Also:
AbstractCommand.AbstractCommand()

GenericCommand

public GenericCommand(Map<String,Object> commandParameters)
               throws IllegalArgumentException,
                      InvalidParameterDefinitionException
Throws:
IllegalArgumentException
InvalidParameterDefinitionException
See Also:
AbstractCommand.AbstractCommand(Map)

GenericCommand

public GenericCommand(Command commandToTransform)
See Also:
AbstractCommand.AbstractCommand(Command)

GenericCommand

public GenericCommand(CommandType commandType,
                      ParameterDefinition[] paramDefs)
Specialized constructor for GenericCommand that allows the instantiator to dynamically define this generic commands metadata at runtime.

Parameters:
commandType - this command type
paramDefs - the definitions for this command's parameters
Method Detail

setCommandType

public void setCommandType(CommandType newCommandType)
Allows the caller to modify this custom command's type. Note that calling this method with a command type that is not understood by a server-side command service will render this command inoperable.

Parameters:
newCommandType - this command's new command type

setParameterDefinitions

public void setParameterDefinitions(ParameterDefinition[] newParameterDefinitions)
Allows the caller to modify this custom command's parameter definitions. Note that calling this method with definitions that are not understood by a server-side command service will render this command inoperable.

The given set of parameter definitions completely override the currently existing definitions (i.e. they are not merged; the new definitions replace the old definitions).

Changing the parameter definitions may invalidate the current set of parameter values. Calling AbstractCommand.checkParameterValidity(boolean) will determine if the current parameter values are still valid for the new parameter definitions.

Parameters:
newParameterDefinitions - this command's new parameter definitions

buildCommandType

protected CommandType buildCommandType()
Description copied from class: AbstractCommand
Builds the command type of this command. It must not be null.

This method is called by the command's constructors.

Specified by:
buildCommandType in class AbstractCommand
Returns:
the command's type definition; must not be null
See Also:
AbstractCommand.buildCommandType()

buildParameterDefinitions

protected ParameterDefinition[] buildParameterDefinitions()
Description copied from class: AbstractCommand
Builds the set of parameter definitions that this command will use. Parameter definitions define what parameters this command accepts. Implementors must return one of the following:

This method is called by the command's constructors.

Specified by:
buildParameterDefinitions in class AbstractCommand
Returns:
an array of parameter definitions or null
See Also:
AbstractCommand.buildParameterDefinitions()


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.