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

JBIInstallCommands

public class JBIInstallCommands extends JBICommand
Will install a component, install a shared library or deploy a service assembly. or service assemblies.
version
$Revision: 1.8 $

Fields Summary
private static final String
INSTALL_COMPONENT
private static final String
INSTALL_SHARED_LIBRARY
private static final String
DEPLOY_SERVICE_ASSEMBLY
Constructors Summary
Methods Summary
private java.util.PropertiescheckForProperties()

        String compProperties = getOption(COMPONENT_PROPERTIES);
        Properties properties = new Properties();
        if (compProperties != "")
        {
            try 
            {
                properties.load(new FileInputStream(compProperties));
            } 
            catch (IOException e) 
            {
                properties = createPropertiesParam(compProperties);
            }
        }
        return properties;
    
public voidrunCommand()
A method that Executes the command

throws
CommandException
throws
CommandValidationException


                      
         
    
        String  result = "";
        String  successKey = "";
        String  errorKey = "";
        boolean installFromDomain = false;
        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  operand = (String) getOperands().get(0);

                // Make sure the file specified is valid. If it is not a valid file, then
                // we should try to install/deploy the component/assembly from the domain.
                // If that should fail, then we will throw the original commandException,
                // saying that the filePath specified was not valid.
                try {
                    if (name.equals(DEPLOY_SERVICE_ASSEMBLY))
                    {
                        errorKey = "JBIDeloymentFileNotFound";
                    }
                    else
                    {
                        errorKey = "JBIInstallationFileNotFound";
                    }
                    operand = validateFilePath (errorKey,operand);
                }
                catch (CommandException ce) {
                    installFromDomain = true;

                    if (name.equals(INSTALL_COMPONENT)) {
                        result = ((JBIAdminCommands) mJbiAdminCommands).installComponentFromDomain(
                                operand,
                                targetName);
                        successKey = "JBISuccessInstallDomainComponent";
                    }

                    else if (name.equals(INSTALL_SHARED_LIBRARY)) {
                        result = ((JBIAdminCommands) mJbiAdminCommands).installSharedLibraryFromDomain(
                                operand,
                                targetName);
                        successKey = "JBISuccessInstallDomainSharedLibrary";
                    }

                    else if (name.equals(DEPLOY_SERVICE_ASSEMBLY)) {
                        result = ((JBIAdminCommands) mJbiAdminCommands).deployServiceAssemblyFromDomain(
                                operand,
                                targetName);
                        successKey = "JBISuccessDeployServiceAssembly";
                    }
                    processJBIAdminResult (result, successKey);
                }

                if (!(installFromDomain))
                {
                    // Using the command name, we'll determine how to process the command
                    if (name.equals(INSTALL_COMPONENT)) {

                        // When installing a component, two api's exist, one when installing
                        // a component with no associated properties, and one when installing
                        // a component with associated properties.
                        Properties properties = checkForProperties();
                        result = ((JBIAdminCommands) mJbiAdminCommands).installComponent(
                                operand,
                                properties,
                                targetName);
                        successKey = "JBISuccessInstallComponent";
                    }

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

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

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