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

VersionCommand

public class VersionCommand extends S1ASCommand
This command will get the version of the application server
version
$Revision: 1.5 $

Fields Summary
private static final String
VERBOSE
private static final String
FULL_VERSION_ATTR
private static final String
SHORT_VERSION_ATTR
Constructors Summary
Methods Summary
private voiddisplayVersionLocally()
This method gets the Version locally

        //if there is problem communicating with admin server, then get version
        //locally
        CLILogger.getInstance().printDetailMessage(getLocalizedString("UnableToCommunicateWithAdminServer"));
        
        if (getBooleanOption("verbose"))
            CLILogger.getInstance().printMessage(getLocalizedString("Version",
                                                 new Object[] {Version.getFullVersion()}));
        else
            CLILogger.getInstance().printMessage(getLocalizedString("Version",
                                                 new Object[] {Version.getVersion()}));
        CLILogger.getInstance().printDetailMessage(getLocalizedString(
                                                       "CommandSuccessful",
                                                       new Object[] {name}));
    
protected java.lang.StringgetPassword()
Returns the password option value. This is used by all asadmin commands that accept the --password option.

return
password returns password option value

        //getPassword(optionName, allowedOnCommandLine, readPrefsFile, readPasswordOptionFromPrefs, readMasterPasswordFile, mgr, config,
        //promptUser, confirm, validate)
        return getPassword(PASSWORD, "AdminPasswordPrompt", "AdminPasswordConfirmationPrompt", 
                            true, true, false, false, null, null, false, false, false, true);       
    
protected java.lang.StringgetUser()

        String userValue = getOption(USER);
        if (userValue == null)
        {
            // read from .asadminpass
            userValue = getUserFromASADMINPASS();
            
            // read from .asadminprefs
            if (userValue == null)
                userValue= getValuesFromASADMINPREFS(USER);
            if (userValue != null)
            {
                CLILogger.getInstance().printDebugMessage(
                                "user value read from " + ASADMINPREFS);
            }
        }
        return userValue;
    
private voidprintDebug(javax.management.MBeanServerConnection mbsc, java.lang.String objectName)
This method prints the objecName info for debugging purpose

        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());
            CLILogger.getInstance().printDebugMessage("****** TYPE *****");
            final javax.management.MBeanParameterInfo[]  mbpi  = mboinfo[ii].getSignature();
            for (int kk=0; kk<mbpi.length; kk++)
            {
                CLILogger.getInstance().printDebugMessage("type = " + mbpi[kk].getType());
            }
            CLILogger.getInstance().printDebugMessage("returnType = " + mboinfo[ii].getReturnType());


        }
    
public voidrunCommand()
An abstract method that Executes the command

throws
CommandException

        //if validateOptions is false, then it must  be that --help option
        //is provided and there is no need to execute the command since
        //either manpage or usage text is displayed
        if (!validateOptions())
            return;

        String objectName = getObjectName();        
        try
        {
            //use http connector
            MBeanServerConnection mbsc = getMBeanServerConnection(getHost(), getPort(),
                                                                  getUser(), getPassword());

            //if (System.getProperty("Debug") != null) 
            //    printDebug(mbsc, objectName);
            String attribute;
            if (getBooleanOption("verbose"))
                attribute = FULL_VERSION_ATTR;
            else
                attribute = SHORT_VERSION_ATTR;

            Object returnValue = mbsc.getAttribute(new ObjectName(objectName),
                                             attribute);
            // handleReturnValue(returnValue);
            CLILogger.getInstance().printMessage(getLocalizedString("Version",
                                                 new Object[] {returnValue}));
            CLILogger.getInstance().printDetailMessage(getLocalizedString(
                                                       "CommandSuccessful",
                                                       new Object[] {name}));
        }
        catch (IOException ioe)
        {
            displayVersionLocally();
        }
        catch (CommandValidationException cve)
        {
            displayVersionLocally();
        }
        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();