admin@glassfish.java.net

[code review]

From: Mark Saunders <Mark.Saunders_at_Sun.COM>
Date: Fri, 29 Sep 2006 14:31:14 -0700

In this integration the remaining JBI commands will be implemented. As
part of implementing the final JBI commands, the classes/files for the
existing commands have been consolidated into 5 classes. This will help
keep the total number of classes down and reduce the amount of code that
will need to be maintained in the future.

New Files:
  JBIInstallCommands.java
  JBIListCommands.java
  JBIShowCommands.java
  JBIUninstallCommands.java
  JBILifecycleCommands.java

Files that will be deleted:
  InstallJBIComponentCommand.java
  InstallJBISharedLibraryCommand.java
  DeployJBIServiceAssemblyCommand.java
  ListJBIBindingComponentsCommand.java
  ListJBIServiceAssembliesCommand.java
  ListJBIServiceEnginesCommand.java
  ListSharedLibrariesCommand.java
  UninstallJBIServiceAssemblyCommand.java
  UninstallJBIComponentCommand.java
  UninstallJBISharedLibraryCommand.java
  JBILifecycleCommand.java

Attached are the diffs, the new files as well as JBICommand.java.
JBICommand.java changed quite a bit, so I thought it would be easier to
review if it was attached.



/*
 * The contents of this file are subject to the terms
 * of the Common Development and Distribution License
 * (the License). You may not use this file except in
 * compliance with the License.
 *
 * You can obtain a copy of the license at
 * https://glassfish.dev.java.net/public/CDDLv1.0.html or
 * glassfish/bootstrap/legal/CDDLv1.0.txt.
 * See the License for the specific language governing
 * permissions and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL
 * Header Notice in each file and include the License file
 * at glassfish/bootstrap/legal/CDDLv1.0.txt.
 * If applicable, add the following below the CDDL Header,
 * with the fields enclosed by brackets [] replaced by
 * you own identifying information:
 * "Portions Copyrighted [year] [name of copyright owner]"
 *
 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
 */

package com.sun.enterprise.cli.commands;

import com.sun.enterprise.cli.framework.CommandValidationException;
import com.sun.enterprise.cli.framework.CommandException;
import com.sun.enterprise.cli.framework.CLILogger;
import com.sun.jbi.ui.common.JBIRemoteException;
import com.sun.jbi.ui.common.JBIAdminCommands;

/**
 * Will perform a lifecycle operation (stop, stop or shutdown) on a component
 * (service engine, binding component) or a service assembly.
 * @version $Revision: 1.2 $
 */
public class JBILifecycleCommands extends JBICommand
{
    private static final String START_COMPONENT = "start-jbi-component";
    private static final String STOP_COMPONENT = "stop-jbi-component";
    private static final String SHUT_DOWN_COMPONENT = "shut-down-jbi-component";
    private static final String START_SERVICE_ASSEMBLY = "start-jbi-service-assembly";
    private static final String STOP_SERVICE_ASSEMBLY = "stop-jbi-service-assembly";
    private static final String SHUT_DOWN_SERVICE_ASSEMBLY = "shut-down-jbi-service-assembly";

    /**
     * A method that Executes the command
     * @throws CommandException
     */
    public void runCommand() throws CommandException, CommandValidationException
    {
        String result = "";
        String successKey = "";
        try {

            // Perform the pre run initialization
            if (preRunInit())
            {
                // Retrieve the options
                String targetName = getOption(TARGET_OPTION);
                boolean force = getBooleanOption(FORCE_OPTION,false);

                // Retrieve the operand "componentName"
                String componentName = (String) getOperands().get(0);

                // Using the command name, we'll determine how to process the command
                if (name.equals(START_COMPONENT)) {
                    result = ((JBIAdminCommands) mJbiAdminCommands).startComponent(
                        componentName,
                        targetName);
                    successKey = "SuccessStartedComponent";
                }

                else if (name.equals(STOP_COMPONENT)) {
                    result = ((JBIAdminCommands) mJbiAdminCommands).stopComponent(
                        componentName,
                        targetName);
                    successKey = "SuccessStoppedComponent";
                }

                else if (name.equals(SHUT_DOWN_COMPONENT)) {
                    result = ((JBIAdminCommands) mJbiAdminCommands).shutdownComponent(
                        componentName,
                        force,
                        targetName);
                    successKey = "SuccessShutDownComponent";
                }
                else if (name.equals(START_SERVICE_ASSEMBLY)) {
                    result = ((JBIAdminCommands) mJbiAdminCommands).startServiceAssembly(
                        componentName,
                        targetName);
                    successKey = "SuccessStartAssemblyComponent";
                }

                else if (name.equals(STOP_SERVICE_ASSEMBLY)) {
                    result = ((JBIAdminCommands) mJbiAdminCommands).stopServiceAssembly(
                        componentName,
                        targetName);
                    successKey = "SuccessStoppedAssembly";
                }

                else if (name.equals(SHUT_DOWN_SERVICE_ASSEMBLY)) {
                    result = ((JBIAdminCommands) mJbiAdminCommands).shutdownServiceAssembly(
                        componentName,
                        targetName);
                    successKey = "SuccessShutDownAssembly";
                }

            }

            // Display the default success message
            CLILogger.getInstance().printDetailMessage (
                    getLocalizedString (successKey,new Object[] {name}));
        }

        catch (Exception e) {
            processTaskException(e);
        }
    }
}


/*
 * The contents of this file are subject to the terms
 * of the Common Development and Distribution License
 * (the License). You may not use this file except in
 * compliance with the License.
 *
 * You can obtain a copy of the license at
 * https://glassfish.dev.java.net/public/CDDLv1.0.html or
 * glassfish/bootstrap/legal/CDDLv1.0.txt.
 * See the License for the specific language governing
 * permissions and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL
 * Header Notice in each file and include the License file
 * at glassfish/bootstrap/legal/CDDLv1.0.txt.
 * If applicable, add the following below the CDDL Header,
 * with the fields enclosed by brackets [] replaced by
 * you own identifying information:
 * "Portions Copyrighted [year] [name of copyright owner]"
 *
 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
 */

package com.sun.enterprise.cli.commands;

import com.sun.enterprise.cli.framework.CommandValidationException;
import com.sun.enterprise.cli.framework.CommandException;
import com.sun.enterprise.cli.framework.CLILogger;
import com.sun.jbi.ui.common.JBIRemoteException;
import com.sun.jbi.ui.common.JBIAdminCommands;

/**
 * Will list the names for the binding components, service engines, shared libraries,
 * or service assemblies.
 * @version $Revision: 1.2 $
 */
public class JBIListCommands extends JBICommand
{
    private static final String LIST_BINDING_COMPONENTS = "list-jbi-binding-components";
    private static final String LIST_SERVICE_ENGINES = "list-jbi-service-engines";
    private static final String LIST_SHARED_LIBRARIES = "list-jbi-shared-libraries";
    private static final String LIST_SERVICE_ASSEMBLIES = "list-jbi-service-assemblies";

    /**
     * A method that Executes the command
     * @throws CommandException
     */
    public void runCommand() throws CommandException, CommandValidationException
    {
        String result = "";
        try {

            // Perform the pre run initialization
            if (preRunInit())
            {
                // Retrieve the options used for this command
                String targetName = getOption(TARGET_OPTION);
                String libraryName = getOption(LIBRARY_NAME_OPTION);
                String assemblyName = getOption(ASSEMBLY_NAME_OPTION);
                String lifecycleState = getOption(LIFECYCLE_STATE_OPTION,validStates);
                String componentName = getOption(COMPONENT_NAME_OPTION);

                // Using the command name, we'll determine how to process the command
                if (name.equals(LIST_BINDING_COMPONENTS)) {
                    if ((libraryName == null) && (assemblyName == null)) {
                        result = ((JBIAdminCommands) mJbiAdminCommands).listBindingComponents(
                                targetName);
                    }
                    else {
                        result = ((JBIAdminCommands) mJbiAdminCommands).listBindingComponents(
                                lifecycleState,
                                libraryName,
                                assemblyName,
                                targetName);
                    }
                    processJBIAdminComponentListResult(result);
                }

                else if (name.equals(LIST_SERVICE_ENGINES)) {
                    if ((libraryName == null) && (assemblyName == null)) {
                        result = ((JBIAdminCommands) mJbiAdminCommands).listServiceEngines(
                                targetName);
                    }
                    else {
                        result = ((JBIAdminCommands) mJbiAdminCommands).listServiceEngines(
                                lifecycleState,
                                libraryName,
                                assemblyName,
                                targetName);
                    }
                    processJBIAdminComponentListResult(result);
                }

                else if (name.equals(LIST_SHARED_LIBRARIES)) {
                    if (componentName == null) {
                        result = ((JBIAdminCommands) mJbiAdminCommands).listSharedLibraries(
                                targetName);
                    }
                    else {
                        result = ((JBIAdminCommands) mJbiAdminCommands).listSharedLibraries(
                                componentName,
                                targetName);
                    }
                    processJBIAdminComponentListResult(result);
                }

                else if (name.equals(LIST_SERVICE_ASSEMBLIES)) {
                    if (componentName == null) {
                        result = ((JBIAdminCommands) mJbiAdminCommands).listServiceAssemblies(
                                targetName);
                    }
                    else {
                        result = ((JBIAdminCommands) mJbiAdminCommands).listServiceAssemblies(
                                lifecycleState,
                                componentName,
                                targetName);
                    }
                    processJBIAdminAsseblyListResult(result);
                }

                // Display the default success message
                CLILogger.getInstance().printDetailMessage (
                        getLocalizedString ("CommandSuccessful",new Object[] {name} ) );
            }
        }

        catch (Exception e) {
            processTaskException(e);
        }
    }
}


/*
 * The contents of this file are subject to the terms
 * of the Common Development and Distribution License
 * (the License). You may not use this file except in
 * compliance with the License.
 *
 * You can obtain a copy of the license at
 * https://glassfish.dev.java.net/public/CDDLv1.0.html or
 * glassfish/bootstrap/legal/CDDLv1.0.txt.
 * See the License for the specific language governing
 * permissions and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL
 * Header Notice in each file and include the License file
 * at glassfish/bootstrap/legal/CDDLv1.0.txt.
 * If applicable, add the following below the CDDL Header,
 * with the fields enclosed by brackets [] replaced by
 * you own identifying information:
 * "Portions Copyrighted [year] [name of copyright owner]"
 *
 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
 */

package com.sun.enterprise.cli.commands;

import com.sun.enterprise.cli.framework.CommandValidationException;
import com.sun.enterprise.cli.framework.CommandException;
import com.sun.enterprise.cli.framework.CLILogger;
import com.sun.jbi.ui.common.JBIRemoteException;
import com.sun.jbi.ui.common.JBIAdminCommands;

/**
 * Will show information about a component, shared library or service assembly.
 * @version $Revision: 1.2 $
 */
public class JBIShowCommands extends JBICommand
{
    private static final String SHOW_BINDING_COMPONENT = "show-jbi-binding-component";
    private static final String SHOW_SERVICE_ENGINE = "show-jbi-service-engine";
    private static final String SHOW_SHARED_LIBRARY = "show-jbi-shared-library";
    private static final String SHOW_SERVICE_ASSEMBLY = "show-jbi-service-assembly";

    /**
     * A method that Executes the command
     * @throws CommandException
     */
    public void runCommand() throws CommandException, CommandValidationException
    {
        String result = "";
        try {

            // Perform the pre run initialization
            if (preRunInit())
            {
                // Retrieve the options used for this command
                String targetName = getOption(TARGET_OPTION);

                // Retrieve the operand "name"
                String componentName = (String) getOperands().get(0);
                
                // Using the command name, we'll determine how to process the command
                if (name.equals(SHOW_BINDING_COMPONENT)) {
                    result = ((JBIAdminCommands) mJbiAdminCommands).showBindingComponent(
                        componentName,
                        "",
                        "",
                        "",
                        targetName);
                }

                else if (name.equals(SHOW_SERVICE_ENGINE)) {
                    result = ((JBIAdminCommands) mJbiAdminCommands).showServiceEngine(
                        componentName,
                        "",
                        "",
                        "",
                        targetName);
                }

                else if (name.equals(SHOW_SHARED_LIBRARY)) {
                    result = ((JBIAdminCommands) mJbiAdminCommands).showSharedLibrary(
                        componentName,
                        "",
                        targetName);
                }

                else if (name.equals(SHOW_SERVICE_ASSEMBLY)) {
                    result = ((JBIAdminCommands) mJbiAdminCommands).showServiceAssembly(
                        componentName,
                        "",
                        "",
                        targetName);
                }
            }
            processJBIAdminShowResult(result);
        }

        catch (Exception e) {
            processTaskException(e);
        }
    }
}


/*
 * The contents of this file are subject to the terms
 * of the Common Development and Distribution License
 * (the License). You may not use this file except in
 * compliance with the License.
 *
 * You can obtain a copy of the license at
 * https://glassfish.dev.java.net/public/CDDLv1.0.html or
 * glassfish/bootstrap/legal/CDDLv1.0.txt.
 * See the License for the specific language governing
 * permissions and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL
 * Header Notice in each file and include the License file
 * at glassfish/bootstrap/legal/CDDLv1.0.txt.
 * If applicable, add the following below the CDDL Header,
 * with the fields enclosed by brackets [] replaced by
 * you own identifying information:
 * "Portions Copyrighted [year] [name of copyright owner]"
 *
 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
 */

package com.sun.enterprise.cli.commands;

import com.sun.enterprise.cli.framework.CommandValidationException;
import com.sun.enterprise.cli.framework.CommandException;
import com.sun.enterprise.cli.framework.CLILogger;
import com.sun.jbi.ui.common.JBIRemoteException;
import com.sun.jbi.ui.common.JBIAdminCommands;

/**
 * Will start the JBI component on the specified target.
 * @version $Revision: 1.2 $
 */
public class JBIUninstallCommands extends JBICommand
{
    private static final String UNINSTALL_COMPONENT = "uninstall-jbi-component";
    private static final String UNINSTALL_SHARED_LIBRARY = "uninstall-jbi-shared-library";
    private static final String UNDEPLOY_SERVICE_ASSEMBLY = "undeploy-jbi-service-assembly";

    /**
     * A method that Executes the command
     * @throws CommandException
     */

    public void runCommand() throws CommandException, CommandValidationException
    {
        String result = "";
        String successKey = "";
        try {

            // Perform the pre run initialization
            if (preRunInit())
            {
                // Retrieve the options
                String targetName = getOption(TARGET_OPTION);

                // Retrieve the operand
                String componentName = (String) getOperands().get(0);

                // Using the command name, we'll determine how to process the command
                if (name.equals(UNINSTALL_COMPONENT)) {
                    result = ((JBIAdminCommands) mJbiAdminCommands).uninstallComponent(
                            componentName,
                            targetName);
                    successKey = "SuccessUninstallComponent";
                }

                else if (name.equals(UNINSTALL_SHARED_LIBRARY)) {
                    result = ((JBIAdminCommands) mJbiAdminCommands).uninstallSharedLibrary(
                            componentName,
                            targetName);
                    successKey = "SuccessUninstallSharedLibrary";
                }

                else if (name.equals(UNDEPLOY_SERVICE_ASSEMBLY)) {
                    result = ((JBIAdminCommands) mJbiAdminCommands).undeployServiceAssembly(
                            componentName,
                            targetName);
                    successKey = "SuccessUndeployServiceAssembly";
                }

                // Display the success message
                CLILogger.getInstance().printDetailMessage (
                        getLocalizedString (successKey,new Object[] {componentName}));
            }
        }

        catch (Exception e) {
            processTaskException(e);
        }
    }
}



/*
 * The contents of this file are subject to the terms
 * of the Common Development and Distribution License
 * (the License). You may not use this file except in
 * compliance with the License.
 *
 * You can obtain a copy of the license at
 * https://glassfish.dev.java.net/public/CDDLv1.0.html or
 * glassfish/bootstrap/legal/CDDLv1.0.txt.
 * See the License for the specific language governing
 * permissions and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL
 * Header Notice in each file and include the License file
 * at glassfish/bootstrap/legal/CDDLv1.0.txt.
 * If applicable, add the following below the CDDL Header,
 * with the fields enclosed by brackets [] replaced by
 * you own identifying information:
 * "Portions Copyrighted [year] [name of copyright owner]"
 *
 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
 */

package com.sun.enterprise.cli.commands;

import com.sun.enterprise.cli.framework.CommandValidationException;
import com.sun.enterprise.cli.framework.CommandException;
import com.sun.enterprise.cli.framework.CLILogger;
import com.sun.jbi.ui.common.JBIRemoteException;
import com.sun.jbi.ui.common.JBIAdminCommands;

/**
 * Will install a component, install a shared library or deploy a service assembly.
 * or service assemblies.
 * @version $Revision: 1.2 $
 */
public class JBIInstallCommands extends JBICommand
{
    private static final String INSTALL_COMPONENT = "install-jbi-component";
    private static final String INSTALL_SHARED_LIBRARY = "install-jbi-shared-library";
    private static final String DEPLOY_SERVICE_ASSEMBLY = "deploy-jbi-service-assembly";

    /**
     * A method that Executes the command
     * @throws CommandException
     */
    public void runCommand() throws CommandException, CommandValidationException
    {
        String result = "";
        String successKey = "";
        try {

            // Retrieve the upload boolean option value
            boolean isUpload = getBooleanOption(UPLOAD_OPTION);

            // Perform the pre run initialization
            if (preRunInit(isUpload))
            {
                // Retrieve the options
                String targetName = getOption(TARGET_OPTION);

                // Retrieve the operand
                String filePath = (String) getOperands().get(0);

                // Make sure the file specified is valid
                validateFilePath ("JBIInstallationFileNotFound",filePath);
        
                // Using the command name, we'll determine how to process the command
                if (name.equals(INSTALL_COMPONENT)) {
                    result = ((JBIAdminCommands) mJbiAdminCommands).installComponent(
                            filePath,
                            targetName);
                    successKey = "SuccessInstallComponent";
                }

                else if (name.equals(INSTALL_SHARED_LIBRARY)) {
                    result = ((JBIAdminCommands) mJbiAdminCommands).installSharedLibrary(
                            filePath,
                            targetName);
                    successKey = "SuccessInstallSharedLibrary";
                }

                else if (name.equals(DEPLOY_SERVICE_ASSEMBLY)) {
                    result = ((JBIAdminCommands) mJbiAdminCommands).deployServiceAssembly(
                            filePath,
                            targetName);
                    successKey = "SuccessDeployServiceAssembly";
                }

                // Display the success message
                CLILogger.getInstance().printDetailMessage (
                        getLocalizedString (successKey,new Object[] {result}));
            }
        }

        catch (Exception e) {
            processTaskException(e);
        }
    }
}


/*
 * The contents of this file are subject to the terms
 * of the Common Development and Distribution License
 * (the License). You may not use this file except in
 * compliance with the License.
 *
 * You can obtain a copy of the license at
 * https://glassfish.dev.java.net/public/CDDLv1.0.html or
 * glassfish/bootstrap/legal/CDDLv1.0.txt.
 * See the License for the specific language governing
 * permissions and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL
 * Header Notice in each file and include the License file
 * at glassfish/bootstrap/legal/CDDLv1.0.txt.
 * If applicable, add the following below the CDDL Header,
 * with the fields enclosed by brackets [] replaced by
 * you own identifying information:
 * "Portions Copyrighted [year] [name of copyright owner]"
 *
 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
 */

package com.sun.enterprise.cli.commands;

import com.sun.enterprise.cli.framework.CommandValidationException;
import com.sun.enterprise.cli.framework.CommandException;
import com.sun.enterprise.cli.framework.CLILogger;
import com.sun.enterprise.cli.framework.*;

import com.sun.jbi.ui.client.JBIAdminCommandsClientFactory;
import com.sun.jbi.ui.common.JBIAdminCommands;
import com.sun.jbi.ui.common.JBIRemoteException;
import com.sun.jbi.ui.common.JBIManagementMessage;
import com.sun.jbi.ui.common.JBIComponentInfo;
import com.sun.jbi.ui.common.ServiceAssemblyInfo;

import javax.management.MBeanServerConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.List;
import java.util.Vector;
import java.io.File;

import java.io.PrintWriter;
import java.io.StringWriter;



/**
 * Will start the JBI component on the specified target.
 * @version $Revision: 1.2 $
 */
public abstract class JBICommand extends S1ASCommand
{
    protected static final String VERBOSE = "verbose";
    protected static final String TERSE = "terse";
    protected static final String TARGET_OPTION = "target";
    protected static final String LIBRARY_NAME_OPTION = "libraryname";
    protected static final String ASSEMBLY_NAME_OPTION = "assemblyname";
    protected static final String COMPONENT_NAME_OPTION = "componentname";
    protected static final String UPLOAD_OPTION = "upload";
    protected static final String ENABLED_OPTION = "enabled";
    protected static final String LIFECYCLE_STATE_OPTION = "lifecyclestate";
    protected static final String FORCE_OPTION = "force";
    
    protected static String[] validStates = {"started","stopped","installed"};

    protected JBIAdminCommands mJbiAdminCommands = null;
    protected MBeanServerConnection mbsc = null;

    /**
     * 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
     */
    public boolean validateOptions() throws CommandValidationException
    {
            return super.validateOptions();
    }

    /**
     * Method that will return the option value or if no option value
     * was specified, the default value will be returned.
     * @param optionName The option name use to retrieve the value
     * @param defaultValue The default value returned if no option value exists
     * @return The option value
     */
    protected String getOption(String optionName, String defaultValue)
    {
        return super.getOption(optionName)==null?defaultValue:getOption(optionName);
    }

    /**
     * Method that will return the option value or if no option value
     * was specified, the default value will be returned.
     * @param optionName The option name use to retrieve the value
     * @param validOptions An array containing a list of valid options
     * @param defaultValue The default value returned if no option value exists
     * @return The option value
     */
    protected String getOption(String optionName, String[] validOptions, String defaultValue) throws CommandValidationException
    {
        boolean found = false;
        String option = getOption(optionName);
        if (option == null)
        {
            option = defaultValue;
            found = true;
        }
        else
        {
            for (int i=0; i<validOptions.length; i++)
            {
                if (option.equals(validOptions[i]))
                {
                    found = true;
                    break;
                }
            }
        }
        if (found) {
            return option;
        }
        else {
            throw new CommandValidationException(getLocalizedString("InvalidValueInOption",
                                                    new Object[]{optionName}));
        }
    }

    /**
     * Method that will return the option value or if no option value
     * was specified, the default value will be returned.
     * @param optionName The option name use to retrieve the value
     * @param validOptions An array containing a list of valid options
     * @return The option value
     */
    protected String getOption(String optionName, String[] validOptions) throws CommandValidationException
    {
        String defaultValue = null;
        return getOption(optionName, validOptions, defaultValue);
    }


    /**
     * Method that will return the option value or if no option value
     * was specified, the default value will be returned.
     * @param optionName The option name use to retrieve the value
     * @param defaultValue The default value returned if no option value exists
     * @return The option value
     */
    protected boolean getBooleanOption(String optionName, boolean defaultValue)
    {
        return super.getOption(optionName)==null?defaultValue:getBooleanOption(optionName);
    }

    /**
     * Debug Method - For testing only
     * Method that will return the usage values that are specified in the
     * usage text string.
     * @return An ArrayList containing the usage options
     */
    public ArrayList getUsageValues ()
    {
        String usageText = getUsageText();
        ArrayList list = new ArrayList();
        int indexStart = usageText.indexOf("--",0);
        while (indexStart != -1)
        {
            int indexEnd = usageText.indexOf(" ",indexStart);
            int indexEnd2 = usageText.indexOf("=",indexStart);
            if (indexEnd2 != -1)
            {
                indexEnd = indexEnd2;
            }
            list.add(usageText.substring(indexStart+2,indexEnd));
            indexStart = usageText.indexOf("--",indexEnd+1);
        }
        return list;
    }


    /**
     * Debug Method - For testing only
     * Method that will validate the usage text in the xml file
     */
    public void validateUsageText() throws CommandValidationException
    {
        // Validate that the name in the usage text is correct
        String usageText = getUsageText();
        int i = usageText.indexOf(name);
        if ((usageText.indexOf(name)) == -1)
        {
            throw new CommandValidationException("Name in \"usage-text\" is NOT " + name);
        }
        int nextIndex = i + name.length();
        String space = usageText.substring(nextIndex,nextIndex+1);
        if (!(space.equals(" ")))
        {
            throw new CommandValidationException("Name in \"usage-text\" is NOT " + name);
        }

        HashMap options = getOptions();
        ArrayList list = getUsageValues();
        if ((list != null) && (options != null))
        {
            // Make sure each option defined in the <ValidOption> tag has an entry
            // in the usage-text string.
            for (Iterator iter = options.entrySet().iterator(); iter.hasNext();)
            {
                Map.Entry entry = (Map.Entry)iter.next();
                String key = (String)entry.getKey();
                String value = (String)entry.getValue();
                if (!(list.contains(key)))
                {
                    // Throw Exception for jUnit Tests
                    System.out.println ("Usage is missing the option: " + key);
                    throw new CommandValidationException("Usage is missing the option: " + key);
                }
            }

            // Now make sure each entry in the usage-text string has a corresponding
            // <ValidOption> tag.
            ValidCommand validCommand = null;
            CLIDescriptorsReader cliDescriptorsReader = CLIDescriptorsReader.getInstance();
            validCommand = cliDescriptorsReader.getCommand(name);
            for (Iterator iter = list.iterator(); iter.hasNext();)
            {
                String value = (String)iter.next();
                if (!(validCommand.hasValidOption(value)))
                {
                   // System.out.println ("usage-text \"" + value + "\" is not a valid option.");
                    throw new CommandValidationException("Option \"" + value + "\" specified in the usage statement is not a valid option.");
                }
            }
        }
    }


    public void validateFilePath (String filePath) throws CommandException
    {
        validateFilePath ("FileDoesNotExist",filePath);
    }


    public void validateFilePath (String errorKey, String filePath) throws CommandException
    {
        File file = new File(filePath);
        if ((!file.exists()) || (file.isDirectory()))
        {
            throw new CommandException(getLocalizedString(errorKey,
                                                    new Object[]{filePath}));
        }
    }


    /**
     * Perform the pre run initialization. This will validate the options as
     * well as retrieve the MBean Server Connection.
     */
    protected boolean preRunInit() throws CommandValidationException,
                                          CommandException,
                                          JBIRemoteException
    {
        boolean uploadFlag = true;
        return preRunInit(uploadFlag);
    }


    /**
     * Perform the pre run initialization. This will validate the options as
     * well as retrieve the MBean Server Connection.
     */
    protected boolean preRunInit(boolean uploadFlag) throws CommandValidationException,
                                                            CommandException,
                                                            JBIRemoteException
    {
        // Validate the options and opeands
        validateOptions();

        // For Testing only -- Will remove later --
        validateUsageText();

        // Retrieve the MBean Server Connection and the JBIAdminCommands object.
        mbsc = getMBeanServerConnection(getHost(),
                                        getPort(),
                                        getUser(),
                                        getPassword());

        // Retrieve the JBI Admin Command object
        try {
            //mJbiAdminCommands = JBIAdminCommandsClientFactory.getInstance(mbsc,uploadFlag);
            mJbiAdminCommands = JBIAdminCommandsClientFactory.getInstance(mbsc);
        }
        catch (Exception e) {
            displayExceptionMessage(e);
        }

        // Make sure we have a valid command object
        if (mJbiAdminCommands == null)
        {
            throw new CommandException(getLocalizedString("CouldNotInvokeCommand",
                                                    new Object[]{name}));
        }
        return true;
    }


    /**
     * Will process the list results for the components (Service Engines,
     * Binding Components and Shared Libraries).
     * was specified, the default value will be returned.
     * @param result The result xml string
     */
    protected void processJBIAdminComponentListResult (String result)
    {
        List list = JBIComponentInfo.readFromXmlText(result);
        if (list.size() == 0)
        {
            CLILogger.getInstance().printDetailMessage (
                    getLocalizedString ("NoElementsToList",new Object[] {result}));
        }
        else
        {
            Iterator it = list.iterator();
            String listBreak = "";
            int count = 0;
            while (it.hasNext())
            {
                JBIComponentInfo info = ((JBIComponentInfo)it.next());
                String name = info.getName();
                System.out.println(name);
            }
        }
    }


    /**
     * Will process the list results for the Service Assemblies
     * @param result The result xml string
     */
    protected void processJBIAdminAsseblyListResult (String result)
    {
        List list = ServiceAssemblyInfo.readFromXmlTextWithProlog(result);
        if (list.size() == 0)
        {
            CLILogger.getInstance().printDetailMessage (
                    getLocalizedString ("NoElementsToList",new Object[] {result}));
        }
        else
        {
            Iterator it = list.iterator();
            String listBreak = "";
            int count = 0;
            while (it.hasNext())
            {
                ServiceAssemblyInfo info = ((ServiceAssemblyInfo)it.next());
                String name = info.getName();
                System.out.println(name);
            }
        }
    }


    /**
     * ** Still Under Development **
     * Will process the show results
     * @param result The result xml string
     */
    protected void processJBIAdminShowResult (String result)
    {
        CLILogger.getInstance().printDetailMessage (result);
    }


    // Will be removed when files using this method are deleted
    protected void processJBIAdminResult (String result)
    {
    }


    /**
     * ** Still Under Development **
     * Will process the task exception to display the error message.
     * @param the exception to process
     */
    protected void processTaskException (Exception ex) throws CommandException
    {
        JBIManagementMessage mgmtMsg = extractJBIManagementMessage(ex);
        if (mgmtMsg == null)
        {
            displayExceptionMessage(ex);
        }
        else
        {
            String msg = mgmtMsg.getMessage();
            CLILogger.getInstance().printDetailMessage (msg);
            CLILogger.getInstance().printDetailMessage (
                    getLocalizedString ("CommandUnSuccessful",new Object[] {name}));
        }
    }


    /**
     * ** Still Under Development **
     * Will extract the JBIManagementMessgae from the Remote exception.
     * @param the exception to process
     */
    protected JBIManagementMessage extractJBIManagementMessage (Exception ex )
    {
        JBIManagementMessage mgmtMsg = null;
        if (ex instanceof JBIRemoteException)
        {
            JBIRemoteException rEx = (JBIRemoteException)ex;
            mgmtMsg = rEx.extractJBIManagementMessage();
        }
        else
        {
            String exMessage = ex.getMessage();
            mgmtMsg = JBIManagementMessage.createJBIManagementMessage(exMessage);
        }
        return mgmtMsg;
    }

}


? admin-cli.log
? build
? diff.txt
? commands/build
? commands/src/java/com/sun/enterprise/cli/Commands.zip
? commands/src/java/com/sun/enterprise/cli/commands/CLIDescriptor.jbi
? commands/src/java/com/sun/enterprise/cli/commands/JBIInstallCommands.java
? commands/src/java/com/sun/enterprise/cli/commands/JBILifecycleCommands.java
? commands/src/java/com/sun/enterprise/cli/commands/JBIListCommands.java
? commands/src/java/com/sun/enterprise/cli/commands/JBIShowCommands.java
? commands/src/java/com/sun/enterprise/cli/commands/JBIUninstallCommands.java
? commands/tests/java/com/sun/enterprise/cli/commands/StartJBIComponentCommandTest.java
? commands/tests/java/com/sun/enterprise/cli/commands/TestLogger.java
? framework/${javadoc.dir}
? framework/build
Index: commands/src/java/com/sun/enterprise/cli/commands/CLIDescriptor.xml
===================================================================
RCS file: /cvs/glassfish/admin-cli/commands/src/java/com/sun/enterprise/cli/commands/CLIDescriptor.xml,v
retrieving revision 1.49
diff -u -r1.49 CLIDescriptor.xml
--- commands/src/java/com/sun/enterprise/cli/commands/CLIDescriptor.xml 13 Sep 2006 04:06:15 -0000 1.49
+++ commands/src/java/com/sun/enterprise/cli/commands/CLIDescriptor.xml 29 Sep 2006 18:07:50 -0000
@@ -287,7 +287,7 @@
                 <Option name="assemblyname" type="string" value-required="false"/>
                 <Option name="componentname" type="string" value-required="false"/>
                 <Option name="libraryname" type="string" value-required="false"/>
- <Option name="lifecyclestate" type="string" value-required="false" default=""/>
+ <Option name="lifecyclestate" type="string" value-required="false"/>
             </Options>
         <Commands>
                 <Command name="backup-domain" classname="com.sun.enterprise.cli.commands.BackupCommands" numberofoperands="?" usage-text="backup-domain [--domaindir domain_directory] [--description description] [--echo=false] [--terse=false] [--verbose=false] [domain_name]">
@@ -5547,91 +5547,84 @@
                         <ValidOption name="port"/>
                         <ValidOption name="secure"/>
                 </Command>
- <Command name="start-jbi-component" classname="com.sun.enterprise.cli.commands.JBILifecycleCommand" numberofoperands="1" usage-text="asadmin start-jbi-component [--terse=false] [--verbose=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] component_name">
+ <Command name="start-jbi-component" classname="com.sun.enterprise.cli.commands.JBILifecycleCommands" numberofoperands="1" usage-text="asadmin start-jbi-component [--terse=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] component_name">
             <ValidOption name="user"/>
             <ValidOption name="host"/>
             <ValidOption name="port"/>
             <ValidOption name="passwordfile"/>
             <ValidOption name="interactive"/>
             <ValidOption name="terse"/>
- <ValidOption name="verbose"/>
             <ValidOption name="secure"/>
             <ValidOption name="target"/>
             <ValidOption name="echo"/>
         </Command>
- <Command name="stop-jbi-component" classname="com.sun.enterprise.cli.commands.JBILifecycleCommand" numberofoperands="1" usage-text="asadmin start-jbi-component [--terse=false] [--verbose=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] component_name">
+ <Command name="stop-jbi-component" classname="com.sun.enterprise.cli.commands.JBILifecycleCommands" numberofoperands="1" usage-text="asadmin stop-jbi-component [--terse=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] component_name">
             <ValidOption name="user"/>
             <ValidOption name="host"/>
             <ValidOption name="port"/>
             <ValidOption name="passwordfile"/>
             <ValidOption name="interactive"/>
             <ValidOption name="terse"/>
- <ValidOption name="verbose"/>
             <ValidOption name="secure"/>
             <ValidOption name="target"/>
             <ValidOption name="echo"/>
         </Command>
- <Command name="shut-down-jbi-component" classname="com.sun.enterprise.cli.commands.JBILifecycleCommand" numberofoperands="1" usage-text="asadmin start-jbi-component [--terse=false] [--verbose=false] [--force=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] component_name">
+ <Command name="shut-down-jbi-component" classname="com.sun.enterprise.cli.commands.JBILifecycleCommands" numberofoperands="1" usage-text="asadmin shut-down-jbi-component [--terse=false] [--force=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] component_name">
             <ValidOption name="user"/>
             <ValidOption name="host"/>
             <ValidOption name="port"/>
             <ValidOption name="passwordfile"/>
             <ValidOption name="interactive"/>
             <ValidOption name="terse"/>
- <ValidOption name="verbose"/>
             <ValidOption name="force"/>
             <ValidOption name="secure"/>
             <ValidOption name="target"/>
             <ValidOption name="echo"/>
         </Command>
- <Command name="install-jbi-component" classname="com.sun.enterprise.cli.commands.InstallJBIComponentCommand" numberofoperands="1" usage-text="asadmin install-jbi-component [--terse=false] [--verbose=false] [--echo=false] [--interactive=true] [--enabled=true] [--upload=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] filepath">
+ <Command name="install-jbi-component" classname="com.sun.enterprise.cli.commands.JBIInstallCommands" numberofoperands="1" usage-text="asadmin install-jbi-component [--terse=false] [--echo=false] [--interactive=true] [--enabled=true] [--upload=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] filepath">
             <ValidOption name="user"/>
             <ValidOption name="host"/>
             <ValidOption name="port"/>
             <ValidOption name="passwordfile"/>
             <ValidOption name="interactive"/>
             <ValidOption name="terse"/>
- <ValidOption name="verbose"/>
             <ValidOption name="secure"/>
             <ValidOption name="enabled"/>
             <ValidOption name="upload"/>
             <ValidOption name="target"/>
             <ValidOption name="echo"/>
         </Command>
- <Command name="install-jbi-shared-library" classname="com.sun.enterprise.cli.commands.InstallJBISharedLibraryCommand" numberofoperands="1" usage-text="asadmin install-jbi-component [--terse=false] [--verbose=false] [--echo=false] [--interactive=true] [--upload=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] filepath">
+ <Command name="install-jbi-shared-library" classname="com.sun.enterprise.cli.commands.JBIInstallCommands" numberofoperands="1" usage-text="asadmin install-jbi-shared-library [--terse=false] [--echo=false] [--interactive=true] [--upload=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] filepath">
             <ValidOption name="user"/>
             <ValidOption name="host"/>
             <ValidOption name="port"/>
             <ValidOption name="passwordfile"/>
             <ValidOption name="interactive"/>
             <ValidOption name="terse"/>
- <ValidOption name="verbose"/>
             <ValidOption name="secure"/>
             <ValidOption name="upload"/>
             <ValidOption name="target"/>
             <ValidOption name="echo"/>
         </Command>
- <Command name="list-jbi-shared-libraries" classname="com.sun.enterprise.cli.commands.ListJBISharedLibrariesCommand" numberofoperands="0" usage-text="asadmin install-jbi-component [--terse=false] [--verbose=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] [--componentname component_name] filepath">
+ <Command name="list-jbi-shared-libraries" classname="com.sun.enterprise.cli.commands.JBIListCommands" numberofoperands="0" usage-text="asadmin list-jbi-shared-libraries [--terse=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] [--componentname component_name]">
             <ValidOption name="user"/>
             <ValidOption name="host"/>
             <ValidOption name="port"/>
             <ValidOption name="passwordfile"/>
             <ValidOption name="interactive"/>
             <ValidOption name="terse"/>
- <ValidOption name="verbose"/>
- <ValidOption name="secure"/>
+ <ValidOption name="secure"/>
             <ValidOption name="target"/>
             <ValidOption name="componentname"/>
             <ValidOption name="echo"/>
         </Command>
- <Command name="list-jbi-service-engines" classname="com.sun.enterprise.cli.commands.ListJBIServiceEnginesCommand" numberofoperands="0" usage-text="asadmin install-jbi-component [--terse=false] [--verbose=false] [--echo=false] [--interactive=true] [--upload=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--lifecyclestate started|stopped|installed] [--target target(Default server)] [--libraryname shared_library_name] [--assemblyname service_assembly_name] filepath">
+ <Command name="list-jbi-service-engines" classname="com.sun.enterprise.cli.commands.JBIListCommands" numberofoperands="0" usage-text="asadmin list-jbi-service-engines [--terse=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--lifecyclestate started|stopped|installed] [--target target(Default server)] [--libraryname shared_library_name] [--assemblyname service_assembly_name]">
             <ValidOption name="user"/>
             <ValidOption name="host"/>
             <ValidOption name="port"/>
             <ValidOption name="passwordfile"/>
             <ValidOption name="interactive"/>
             <ValidOption name="terse"/>
- <ValidOption name="verbose"/>
             <ValidOption name="secure"/>
             <ValidOption name="target"/>
             <ValidOption name="lifecyclestate"/>
@@ -5639,14 +5632,13 @@
             <ValidOption name="assemblyname"/>
             <ValidOption name="echo"/>
         </Command>
- <Command name="list-jbi-binding-components" classname="com.sun.enterprise.cli.commands.ListJBIBindingComponentsCommand" numberofoperands="0" usage-text="asadmin install-jbi-component [--terse=false] [--verbose=false] [--echo=false] [--interactive=true] [--upload=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--lifecyclestate started|stopped|installed] [--target target(Default server)] [--libraryname shared_library_name] [--assemblyname service_assembly_name] filepath">
+ <Command name="list-jbi-binding-components" classname="com.sun.enterprise.cli.commands.JBIListCommands" numberofoperands="0" usage-text="asadmin list-jbi-binding-components [--terse=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--lifecyclestate started|stopped|installed] [--target target(Default server)] [--libraryname shared_library_name] [--assemblyname service_assembly_name]">
             <ValidOption name="user"/>
             <ValidOption name="host"/>
             <ValidOption name="port"/>
             <ValidOption name="passwordfile"/>
             <ValidOption name="interactive"/>
             <ValidOption name="terse"/>
- <ValidOption name="verbose"/>
             <ValidOption name="secure"/>
             <ValidOption name="target"/>
             <ValidOption name="lifecyclestate"/>
@@ -5654,105 +5646,142 @@
             <ValidOption name="assemblyname"/>
             <ValidOption name="echo"/>
         </Command>
- <Command name="list-jbi-service-assemblies" classname="com.sun.enterprise.cli.commands.ListJBIServiceAssembliesCommand" numberofoperands="0" usage-text="asadmin install-jbi-component [--terse=false] [--verbose=false] [--echo=false] [--interactive=true] [--upload=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--lifecyclestate started|stopped|installed] [--target target(Default server)] [--componentname component_name] filepath">
+ <Command name="list-jbi-service-assemblies" classname="com.sun.enterprise.cli.commands.JBIListCommands" numberofoperands="0" usage-text="asadmin list-jbi-service-assemblies [--terse=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--lifecyclestate started|stopped|installed] [--target target(Default server)] [--componentname component_name]">
             <ValidOption name="user"/>
             <ValidOption name="host"/>
             <ValidOption name="port"/>
             <ValidOption name="passwordfile"/>
             <ValidOption name="interactive"/>
             <ValidOption name="terse"/>
- <ValidOption name="verbose"/>
             <ValidOption name="secure"/>
             <ValidOption name="target"/>
             <ValidOption name="lifecyclestate"/>
             <ValidOption name="componentname"/>
             <ValidOption name="echo"/>
         </Command>
- <Command name="deploy-jbi-service-assembly" classname="com.sun.enterprise.cli.commands.DeployJBIServiceAssemblyCommand" numberofoperands="1" usage-text="asadmin install-jbi-component [--terse=false] [--verbose=false] [--echo=false] [--interactive=true] [--enabled=true] [--upload=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] filepath">
+ <Command name="deploy-jbi-service-assembly" classname="com.sun.enterprise.cli.commands.JBIInstallCommands" numberofoperands="1" usage-text="asadmin deploy-jbi-service-assembly [--terse=false] [--echo=false] [--interactive=true] [--enabled=true] [--upload=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] filepath">
             <ValidOption name="user"/>
             <ValidOption name="host"/>
             <ValidOption name="port"/>
             <ValidOption name="passwordfile"/>
             <ValidOption name="interactive"/>
             <ValidOption name="terse"/>
- <ValidOption name="verbose"/>
             <ValidOption name="secure"/>
             <ValidOption name="enabled"/>
             <ValidOption name="upload"/>
             <ValidOption name="target"/>
             <ValidOption name="echo"/>
         </Command>
- <Command name="undeploy-jbi-service-assembly" classname="com.sun.enterprise.cli.commands.UndeployJBIServiceAssemblyCommand" numberofoperands="1" usage-text="asadmin install-jbi-component [--terse=false] [--verbose=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] filepath">
+ <Command name="undeploy-jbi-service-assembly" classname="com.sun.enterprise.cli.commands.JBIUninstallCommands" numberofoperands="1" usage-text="asadmin undeploy-jbi-service-assembly [--terse=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] seervice_assembly_name">
+ <ValidOption name="user"/>
+ <ValidOption name="host"/>
+ <ValidOption name="port"/>
+ <ValidOption name="passwordfile"/>
+ <ValidOption name="interactive"/>
+ <ValidOption name="terse"/>
+ <ValidOption name="secure"/>
+ <ValidOption name="target"/>
+ <ValidOption name="echo"/>
+ </Command>
+ <Command name="uninstall-jbi-component" classname="com.sun.enterprise.cli.commands.JBIUninstallCommands" numberofoperands="1" usage-text="asadmin uninstall-jbi-component [--terse=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] component_name">
+ <ValidOption name="user"/>
+ <ValidOption name="host"/>
+ <ValidOption name="port"/>
+ <ValidOption name="passwordfile"/>
+ <ValidOption name="interactive"/>
+ <ValidOption name="terse"/>
+ <ValidOption name="secure"/>
+ <ValidOption name="target"/>
+ <ValidOption name="echo"/>
+ </Command>
+ <Command name="uninstall-jbi-shared-library" classname="com.sun.enterprise.cli.commands.JBIUninstallCommands" numberofoperands="1" usage-text="asadmin uninstall-jbi-shared-library [--terse=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] shared_library_name">
+ <ValidOption name="user"/>
+ <ValidOption name="host"/>
+ <ValidOption name="port"/>
+ <ValidOption name="passwordfile"/>
+ <ValidOption name="interactive"/>
+ <ValidOption name="terse"/>
+ <ValidOption name="secure"/>
+ <ValidOption name="target"/>
+ <ValidOption name="echo"/>
+ </Command>
+ <Command name="start-jbi-service-assembly" classname="com.sun.enterprise.cli.commands.JBILifecycleCommands" numberofoperands="1" usage-text="asadmin start-jbi-service-assembly [--terse=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] service_assembly_name">
+ <ValidOption name="user"/>
+ <ValidOption name="host"/>
+ <ValidOption name="port"/>
+ <ValidOption name="passwordfile"/>
+ <ValidOption name="interactive"/>
+ <ValidOption name="terse"/>
+ <ValidOption name="secure"/>
+ <ValidOption name="target"/>
+ <ValidOption name="echo"/>
+ </Command>
+ <Command name="stop-jbi-service-assembly" classname="com.sun.enterprise.cli.commands.JBILifecycleCommands" numberofoperands="1" usage-text="asadmin stop-jbi-service-assembly [--terse=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] service_assembly_name">
             <ValidOption name="user"/>
             <ValidOption name="host"/>
             <ValidOption name="port"/>
             <ValidOption name="passwordfile"/>
             <ValidOption name="interactive"/>
             <ValidOption name="terse"/>
- <ValidOption name="verbose"/>
             <ValidOption name="secure"/>
             <ValidOption name="target"/>
             <ValidOption name="echo"/>
         </Command>
- <Command name="uninstall-jbi-component" classname="com.sun.enterprise.cli.commands.UninstallJBIComponentCommand" numberofoperands="1" usage-text="asadmin install-jbi-component [--terse=false] [--verbose=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] filepath">
+ <Command name="shut-down-jbi-service-assembly" classname="com.sun.enterprise.cli.commands.JBILifecycleCommands" numberofoperands="1" usage-text="asadmin shut-down-jbi-service-assembly [--terse=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] service_assembly_name">
             <ValidOption name="user"/>
             <ValidOption name="host"/>
             <ValidOption name="port"/>
             <ValidOption name="passwordfile"/>
             <ValidOption name="interactive"/>
             <ValidOption name="terse"/>
- <ValidOption name="verbose"/>
             <ValidOption name="secure"/>
             <ValidOption name="target"/>
             <ValidOption name="echo"/>
         </Command>
- <Command name="uninstall-jbi-shared-library" classname="com.sun.enterprise.cli.commands.UninstallJBISharedLibraryCommand" numberofoperands="1" usage-text="asadmin install-jbi-component [--terse=false] [--verbose=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] filepath">
+ <Command name="show-jbi-service-assembly" classname="com.sun.enterprise.cli.commands.JBIShowCommands" numberofoperands="1" usage-text="asadmin show-jbi-service-assembly [--terse=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] service_assembly_name">
             <ValidOption name="user"/>
             <ValidOption name="host"/>
             <ValidOption name="port"/>
             <ValidOption name="passwordfile"/>
             <ValidOption name="interactive"/>
             <ValidOption name="terse"/>
- <ValidOption name="verbose"/>
             <ValidOption name="secure"/>
             <ValidOption name="target"/>
             <ValidOption name="echo"/>
         </Command>
- <Command name="start-jbi-service-assembly" classname="com.sun.enterprise.cli.commands.JBILifecycleCommand" numberofoperands="1" usage-text="asadmin start-jbi-component [--terse=false] [--verbose=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] component_name">
+ <Command name="show-jbi-service-engine" classname="com.sun.enterprise.cli.commands.JBIShowCommands" numberofoperands="1" usage-text="asadmin show-jbi-service-engine [--terse=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] service_assembly_name">
             <ValidOption name="user"/>
             <ValidOption name="host"/>
             <ValidOption name="port"/>
             <ValidOption name="passwordfile"/>
             <ValidOption name="interactive"/>
             <ValidOption name="terse"/>
- <ValidOption name="verbose"/>
             <ValidOption name="secure"/>
             <ValidOption name="target"/>
             <ValidOption name="echo"/>
         </Command>
- <Command name="stop-jbi-service-assembly" classname="com.sun.enterprise.cli.commands.JBILifecycleCommand" numberofoperands="1" usage-text="asadmin start-jbi-component [--terse=false] [--verbose=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] component_name">
+ <Command name="show-jbi-binding-component" classname="com.sun.enterprise.cli.commands.JBIShowCommands" numberofoperands="1" usage-text="asadmin show-jbi-binding-component [--terse=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] service_assembly_name">
             <ValidOption name="user"/>
             <ValidOption name="host"/>
             <ValidOption name="port"/>
             <ValidOption name="passwordfile"/>
             <ValidOption name="interactive"/>
             <ValidOption name="terse"/>
- <ValidOption name="verbose"/>
             <ValidOption name="secure"/>
             <ValidOption name="target"/>
             <ValidOption name="echo"/>
         </Command>
- <Command name="shut-down-jbi-service-assembly" classname="com.sun.enterprise.cli.commands.JBILifecycleCommand" numberofoperands="1" usage-text="asadmin start-jbi-component [--terse=false] [--verbose=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] component_name">
+ <Command name="show-jbi-shared-library" classname="com.sun.enterprise.cli.commands.JBIShowCommands" numberofoperands="1" usage-text="asadmin show-jbi-shared-library [--terse=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--target target(Default server)] service_assembly_name">
             <ValidOption name="user"/>
             <ValidOption name="host"/>
             <ValidOption name="port"/>
             <ValidOption name="passwordfile"/>
             <ValidOption name="interactive"/>
             <ValidOption name="terse"/>
- <ValidOption name="verbose"/>
             <ValidOption name="secure"/>
             <ValidOption name="target"/>
             <ValidOption name="echo"/>
         </Command>
+
     </Commands>
 </CommandsAndOptions>
Index: commands/src/java/com/sun/enterprise/cli/commands/JBICommand.java
===================================================================
RCS file: /cvs/glassfish/admin-cli/commands/src/java/com/sun/enterprise/cli/commands/JBICommand.java,v
retrieving revision 1.2
diff -u -r1.2 JBICommand.java
--- commands/src/java/com/sun/enterprise/cli/commands/JBICommand.java 13 Sep 2006 04:06:15 -0000 1.2
+++ commands/src/java/com/sun/enterprise/cli/commands/JBICommand.java 29 Sep 2006 20:38:06 -0000
@@ -26,14 +26,27 @@
 import com.sun.enterprise.cli.framework.CommandValidationException;
 import com.sun.enterprise.cli.framework.CommandException;
 import com.sun.enterprise.cli.framework.CLILogger;
+import com.sun.enterprise.cli.framework.*;
+
 import com.sun.jbi.ui.client.JBIAdminCommandsClientFactory;
 import com.sun.jbi.ui.common.JBIAdminCommands;
 import com.sun.jbi.ui.common.JBIRemoteException;
+import com.sun.jbi.ui.common.JBIManagementMessage;
+import com.sun.jbi.ui.common.JBIComponentInfo;
+import com.sun.jbi.ui.common.ServiceAssemblyInfo;
+
 import javax.management.MBeanServerConnection;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.List;
+import java.util.Vector;
+import java.io.File;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
 
 
 /**
@@ -53,7 +66,7 @@
     protected static final String LIFECYCLE_STATE_OPTION = "lifecyclestate";
     protected static final String FORCE_OPTION = "force";
     
- protected static String[] validStates = {"started","stopped","installed",""};
+ protected static String[] validStates = {"started","stopped","installed"};
 
     protected JBIAdminCommands mJbiAdminCommands = null;
     protected MBeanServerConnection mbsc = null;
@@ -82,25 +95,32 @@
         return super.getOption(optionName)==null?defaultValue:getOption(optionName);
     }
 
-
     /**
      * Method that will return the option value or if no option value
      * was specified, the default value will be returned.
      * @param optionName The option name use to retrieve the value
+ * @param validOptions An array containing a list of valid options
      * @param defaultValue The default value returned if no option value exists
      * @return The option value
      */
- protected String getOption(String optionName, String[] validOptions) throws CommandValidationException
+ protected String getOption(String optionName, String[] validOptions, String defaultValue) throws CommandValidationException
     {
         boolean found = false;
         String option = getOption(optionName);
- System.out.println ("option: " + option);
- for (int i=0; i<validOptions.length; i++)
+ if (option == null)
         {
- if (option.equals(validOptions[i]))
+ option = defaultValue;
+ found = true;
+ }
+ else
+ {
+ for (int i=0; i<validOptions.length; i++)
             {
- found = true;
- break;
+ if (option.equals(validOptions[i]))
+ {
+ found = true;
+ break;
+ }
             }
         }
         if (found) {
@@ -112,6 +132,19 @@
         }
     }
 
+ /**
+ * Method that will return the option value or if no option value
+ * was specified, the default value will be returned.
+ * @param optionName The option name use to retrieve the value
+ * @param validOptions An array containing a list of valid options
+ * @return The option value
+ */
+ protected String getOption(String optionName, String[] validOptions) throws CommandValidationException
+ {
+ String defaultValue = null;
+ return getOption(optionName, validOptions, defaultValue);
+ }
+
 
     /**
      * Method that will return the option value or if no option value
@@ -150,30 +183,33 @@
         return list;
     }
 
+
     /**
      * Debug Method - For testing only
      * Method that will validate the usage text in the xml file
      */
     public void validateUsageText() throws CommandValidationException
     {
- ArrayList excludedOptions = new ArrayList();
- excludedOptions.add("user");
- excludedOptions.add("passwordfile");
- excludedOptions.add("password");
- validateUsageText(excludedOptions);
- }
+ // Validate that the name in the usage text is correct
+ String usageText = getUsageText();
+ int i = usageText.indexOf(name);
+ if ((usageText.indexOf(name)) == -1)
+ {
+ throw new CommandValidationException("Name in \"usage-text\" is NOT " + name);
+ }
+ int nextIndex = i + name.length();
+ String space = usageText.substring(nextIndex,nextIndex+1);
+ if (!(space.equals(" ")))
+ {
+ throw new CommandValidationException("Name in \"usage-text\" is NOT " + name);
+ }
 
- /**
- * Debug Method - For testing only
- * Method that will validate the usage text in the xml file
- */
- public void validateUsageText(ArrayList excludedOptions) throws CommandValidationException
- {
         HashMap options = getOptions();
         ArrayList list = getUsageValues();
         if ((list != null) && (options != null))
         {
- // Make sure each option is also documented in the usage text
+ // Make sure each option defined in the <ValidOption> tag has an entry
+ // in the usage-text string.
             for (Iterator iter = options.entrySet().iterator(); iter.hasNext();)
             {
                 Map.Entry entry = (Map.Entry)iter.next();
@@ -187,24 +223,41 @@
                 }
             }
 
- // Make sure each option in the usage state is a valid option
- // HashMap options = getOptions();
+ // Now make sure each entry in the usage-text string has a corresponding
+ // <ValidOption> tag.
+ ValidCommand validCommand = null;
+ CLIDescriptorsReader cliDescriptorsReader = CLIDescriptorsReader.getInstance();
+ validCommand = cliDescriptorsReader.getCommand(name);
             for (Iterator iter = list.iterator(); iter.hasNext();)
             {
                 String value = (String)iter.next();
- if (!excludedOptions.contains(value))
+ if (!(validCommand.hasValidOption(value)))
                 {
- if (!(options.containsKey(value)))
- {
- // Throw Exception for jUnit Tests
- System.out.println ("Option specified in the usage statement is not a valid option: " + value);
- throw new CommandValidationException("Option specified in the usage statement is not a valid option: " + value);
- }
+ // System.out.println ("usage-text \"" + value + "\" is not a valid option.");
+ throw new CommandValidationException("Option \"" + value + "\" specified in the usage statement is not a valid option.");
                 }
             }
         }
     }
 
+
+ public void validateFilePath (String filePath) throws CommandException
+ {
+ validateFilePath ("FileDoesNotExist",filePath);
+ }
+
+
+ public void validateFilePath (String errorKey, String filePath) throws CommandException
+ {
+ File file = new File(filePath);
+ if ((!file.exists()) || (file.isDirectory()))
+ {
+ throw new CommandException(getLocalizedString(errorKey,
+ new Object[]{filePath}));
+ }
+ }
+
+
     /**
      * Perform the pre run initialization. This will validate the options as
      * well as retrieve the MBean Server Connection.
@@ -213,11 +266,24 @@
                                           CommandException,
                                           JBIRemoteException
     {
+ boolean uploadFlag = true;
+ return preRunInit(uploadFlag);
+ }
+
+
+ /**
+ * Perform the pre run initialization. This will validate the options as
+ * well as retrieve the MBean Server Connection.
+ */
+ protected boolean preRunInit(boolean uploadFlag) throws CommandValidationException,
+ CommandException,
+ JBIRemoteException
+ {
         // Validate the options and opeands
         validateOptions();
 
         // For Testing only -- Will remove later --
- // validateUsageText();
+ validateUsageText();
 
         // Retrieve the MBean Server Connection and the JBIAdminCommands object.
         mbsc = getMBeanServerConnection(getHost(),
@@ -227,6 +293,7 @@
 
         // Retrieve the JBI Admin Command object
         try {
+ //mJbiAdminCommands = JBIAdminCommandsClientFactory.getInstance(mbsc,uploadFlag);
             mJbiAdminCommands = JBIAdminCommandsClientFactory.getInstance(mbsc);
         }
         catch (Exception e) {
@@ -239,29 +306,124 @@
             throw new CommandException(getLocalizedString("CouldNotInvokeCommand",
                                                     new Object[]{name}));
         }
+ return true;
+ }
 
- // Throw an exception if the JBI Runtime is not available.
- if (!(mJbiAdminCommands.isJBIRuntimeEnabled()))
+
+ /**
+ * Will process the list results for the components (Service Engines,
+ * Binding Components and Shared Libraries).
+ * was specified, the default value will be returned.
+ * @param result The result xml string
+ */
+ protected void processJBIAdminComponentListResult (String result)
+ {
+ List list = JBIComponentInfo.readFromXmlText(result);
+ if (list.size() == 0)
         {
- throw new CommandException(getLocalizedString("JBIRuntimeNotAvailable",
- new Object[]{name}));
+ CLILogger.getInstance().printDetailMessage (
+ getLocalizedString ("NoElementsToList",new Object[] {result}));
+ }
+ else
+ {
+ Iterator it = list.iterator();
+ String listBreak = "";
+ int count = 0;
+ while (it.hasNext())
+ {
+ JBIComponentInfo info = ((JBIComponentInfo)it.next());
+ String name = info.getName();
+ System.out.println(name);
+ }
         }
+ }
 
- return true;
+
+ /**
+ * Will process the list results for the Service Assemblies
+ * @param result The result xml string
+ */
+ protected void processJBIAdminAsseblyListResult (String result)
+ {
+ List list = ServiceAssemblyInfo.readFromXmlTextWithProlog(result);
+ if (list.size() == 0)
+ {
+ CLILogger.getInstance().printDetailMessage (
+ getLocalizedString ("NoElementsToList",new Object[] {result}));
+ }
+ else
+ {
+ Iterator it = list.iterator();
+ String listBreak = "";
+ int count = 0;
+ while (it.hasNext())
+ {
+ ServiceAssemblyInfo info = ((ServiceAssemblyInfo)it.next());
+ String name = info.getName();
+ System.out.println(name);
+ }
+ }
+ }
+
+
+ /**
+ * ** Still Under Development **
+ * Will process the show results
+ * @param result The result xml string
+ */
+ protected void processJBIAdminShowResult (String result)
+ {
+ CLILogger.getInstance().printDetailMessage (result);
     }
 
 
- // This method is still under development. It currently only
- // dumps the result string passed in to the screen.
- // Note: Still need to I18N all messages.
+ // Will be removed when files using this method are deleted
     protected void processJBIAdminResult (String result)
     {
- if (result == null) {
- CLILogger.getInstance().printDetailMessage ("No Result Found!");
+ }
+
+
+ /**
+ * ** Still Under Development **
+ * Will process the task exception to display the error message.
+ * @param the exception to process
+ */
+ protected void processTaskException (Exception ex) throws CommandException
+ {
+ JBIManagementMessage mgmtMsg = extractJBIManagementMessage(ex);
+ if (mgmtMsg == null)
+ {
+ displayExceptionMessage(ex);
         }
+ else
+ {
+ String msg = mgmtMsg.getMessage();
+ CLILogger.getInstance().printDetailMessage (msg);
+ CLILogger.getInstance().printDetailMessage (
+ getLocalizedString ("CommandUnSuccessful",new Object[] {name}));
+ }
+ }
 
- // For now we'll just print the xml result string
- CLILogger.getInstance().printDetailMessage (result);
+
+ /**
+ * ** Still Under Development **
+ * Will extract the JBIManagementMessgae from the Remote exception.
+ * @param the exception to process
+ */
+ protected JBIManagementMessage extractJBIManagementMessage (Exception ex )
+ {
+ JBIManagementMessage mgmtMsg = null;
+ if (ex instanceof JBIRemoteException)
+ {
+ JBIRemoteException rEx = (JBIRemoteException)ex;
+ mgmtMsg = rEx.extractJBIManagementMessage();
+ }
+ else
+ {
+ String exMessage = ex.getMessage();
+ mgmtMsg = JBIManagementMessage.createJBIManagementMessage(exMessage);
+ }
+ return mgmtMsg;
     }
 
 }
Index: commands/src/java/com/sun/enterprise/cli/commands/LocalStrings.properties
===================================================================
RCS file: /cvs/glassfish/admin-cli/commands/src/java/com/sun/enterprise/cli/commands/LocalStrings.properties,v
retrieving revision 1.38
diff -u -r1.38 LocalStrings.properties
--- commands/src/java/com/sun/enterprise/cli/commands/LocalStrings.properties 19 Sep 2006 00:38:13 -0000 1.38
+++ commands/src/java/com/sun/enterprise/cli/commands/LocalStrings.properties 25 Sep 2006 18:14:57 -0000
@@ -75,6 +75,13 @@
 database.driver.name.msg=Clients can connect to the database using: [{0}].
 database.driver.version.msg=Database Driver Version: [{0}]
 jdbc.version.msg=JDBC Specification Version: [{0}]
+SuccessInstallSharedLibrary=Installed shared library {0}.
+SuccessInstallComponent=Installed component {0}.
+SuccessDeployServiceAssembly=Deployed service assembly {0}.
+SuccessUninstallSharedLibrary=Uninstalled shared library {0}.
+SuccessUninstallComponent=Uninstalled component {0}.
+SuccessUndeployServiceAssembly=Undeployed service assembly {0}.
+
 
 #Error Messages
 CouldNotInvokeCommand=CLI126 Error invoking command, {0}
@@ -211,4 +218,6 @@
 FileNotReadable=CLI197 The file, {0}, is not readable.
 TargetNotAnInstance=CLI198 Specified target {0} is not an instance.
 InstanceNotRunning=CLI199 Instance {0} is not running. Please start the instance first.
-JBIRuntimeNotAvailable=CLI200 The JBI Runtime is not avaliable, Unable to execute the command {0}.
+JBIRuntimeNotAvailable=CLI200 The JBI Runtime is not avaliable. Unable to execute the command {0}.
+JBIInstallationFileNotFound=CLI201 Installation failed. The file {0} could not be found.
+JBIDeloymentFileNotFound=CLI201 Deployment failed. The file {0} could not be found.
Index: commands/tests/java/com/sun/enterprise/cli/commands/AllTest.java
===================================================================
RCS file: /cvs/glassfish/admin-cli/commands/tests/java/com/sun/enterprise/cli/commands/AllTest.java,v
retrieving revision 1.4
diff -u -r1.4 AllTest.java
--- commands/tests/java/com/sun/enterprise/cli/commands/AllTest.java 25 Dec 2005 03:46:42 -0000 1.4
+++ commands/tests/java/com/sun/enterprise/cli/commands/AllTest.java 6 Sep 2006 18:42:48 -0000
@@ -60,6 +60,7 @@
         UnsetCommandTest.class,
         VerifyDomainXmlCommandTest.class,
         WebServiceRegistryCommandTest.class,
+ StartJBIComponentCommandTest.class,
     };
     
     public static Test suite(){