FileDocCategorySizeDatePackage
GenericCommand.javaAPI DocGlassfish v2 API5907Fri May 04 22:25:10 BST 2007com.sun.enterprise.cli.commands

GenericCommand

public class GenericCommand extends S1ASCommand
This is a sample Deploy command
version
$Revision: 1.6 $

Fields Summary
Constructors Summary
Methods Summary
private voidprintDebug(javax.management.MBeanServerConnection mbsc, java.lang.String objectName)

        CLILogger.getInstance().printDebugMessage("********** queryNames **********");
        CLILogger.getInstance().printDebugMessage("LIST OF ALL REGISTERED MBEANS:");
        final java.util.Set allMBeans = mbsc.queryNames( null, null);
        int jj=1;
        for (java.util.Iterator ii = allMBeans.iterator(); ii.hasNext(); ) {
            ObjectName name = (ObjectName) ii.next();
            CLILogger.getInstance().printDebugMessage("("+ jj++ + ")  " + name.toString());
        }


        CLILogger.getInstance().printDebugMessage("********** getMBeanInfo **********");
        final javax.management.MBeanInfo mbinfo = mbsc.getMBeanInfo(new ObjectName(objectName));
        CLILogger.getInstance().printDebugMessage("Description = " + mbinfo.getDescription());
        CLILogger.getInstance().printDebugMessage("Classname = " + mbinfo.getClassName());
        final javax.management.MBeanOperationInfo[] mboinfo = mbinfo.getOperations();
        for (int ii=0; ii<mboinfo.length; ii++) 
        {
            CLILogger.getInstance().printDebugMessage("("+ii+") Description = " + 
                                                      mboinfo[ii].getDescription());
            CLILogger.getInstance().printDebugMessage("("+ii+") Name = " + 
                                                      mboinfo[ii].getName());
        }

    
public voidrunCommand()
An abstract method that Executes the command

throws
CommandException

        if (!validateOptions())
            throw new CommandValidationException("Validation is false");
            //use http connector
        MBeanServerConnection mbsc = getMBeanServerConnection(getHost(), getPort(), 
                                                              getUser(), getPassword());
        final String objectName = getObjectName();
        final Object[] params = getParamsInfo();
        final String operationName = getOperationName();
        final String[] types = getTypesInfo();

        try
        { 
	    //if (System.getProperty("Debug") != null) printDebug(mbsc, objectName);
            Object returnValue = mbsc.invoke(new ObjectName(objectName), 
					     operationName, params, types);
            handleReturnValue(returnValue);
	    CLILogger.getInstance().printDetailMessage(getLocalizedString(
						       "CommandSuccessful",
						       new Object[] {name}));
        }
        catch(Exception e)
        {
            displayExceptionMessage(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();