ShowComponentStatusCommandpublic class ShowComponentStatusCommand extends S1ASCommand This class is called for the show-comonent-status command.
It uses the application mbean (object name: ias:type=applications,category=config)
and the getStatus operation. This information is defined in
CLIDescriptor.xml,
The getStatus returns true if component is enabled else returns false.
|
Methods Summary |
---|
private void | displayComponentStatus(java.lang.Object returnValue)display the status of the component.
if the returnValue is true, then the component is enabled, else disabled.
final String componentName = (String) getOperands().get(0);
if (returnValue == null)
throw new CommandException(getLocalizedString("UndetermineStatus",
new Object[] {componentName}));
else
{
//the return value must be Boolean
final String returnValClassName = returnValue.getClass().getName();
if (returnValClassName.equals(BOOLEAN_CLASS))
{
final boolean status = ((Boolean)returnValue).booleanValue();
if (status)
CLILogger.getInstance().printMessage(getLocalizedString(
"ComponentIsEnabled", new Object[] {componentName}));
else
CLILogger.getInstance().printMessage(getLocalizedString(
"ComponentIsDisabled", new Object[] {componentName}));
}
else
throw new CommandException(getLocalizedString("UndetermineStatus",
new Object[] {componentName}));
}
| public void | runCommand()An abstract method that Executes the command
validateOptions();
String objectName = getObjectName();
Object[] params = getParamsInfo();
String operationName = getOperationName();
String[] types = getTypesInfo();
//use http connector
MBeanServerConnection mbsc = getMBeanServerConnection(getHost(), getPort(),
getUser(), getPassword());
try
{
final Object returnValue = mbsc.invoke(new ObjectName(objectName),
operationName, params, types);
displayComponentStatus(returnValue);
CLILogger.getInstance().printDetailMessage(getLocalizedString(
"CommandSuccessful",
new Object[] {name}));
}
catch(Exception e)
{
if (e.getLocalizedMessage() != null)
CLILogger.getInstance().printDetailMessage(e.getLocalizedMessage());
throw new CommandException(getLocalizedString("CommandUnSuccessful",
new Object[] {name} ), e);
}
| public boolean | validateOptions()An abstract method that validates the options
on the specification in the xml properties file
This method verifies for the correctness of number of
operands and if all the required options are supplied by the client.
return super.validateOptions();
|
|