FileDocCategorySizeDatePackage
ShowComponentStatusCommand.javaAPI DocGlassfish v2 API5918Fri May 04 22:25:12 BST 2007com.sun.enterprise.cli.commands

ShowComponentStatusCommand

public 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.

version
$Revision: 1.4 $

Fields Summary
Constructors Summary
Methods Summary
private voiddisplayComponentStatus(java.lang.Object returnValue)
display the status of the component. if the returnValue is true, then the component is enabled, else disabled.

throws
CommandException is could not determine the status of the component.

	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 voidrunCommand()
An abstract method that Executes the command

throws
CommandException

        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 booleanvalidateOptions()
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
boolean returns true if success else returns false

    	return super.validateOptions();