Interface SystemUtilService

  • All Superinterfaces:
    Service

    public interface SystemUtilService
    extends Service
    This class performs system-level operations, e.g., setting up environment variables, rebooting the system, startup commands, and OS properties.
    • Field Detail

      • NAME

        static final java.lang.String NAME
      • SYSTEM_LEVEL_ENVIRONMENT_VARIABLE

        static final int SYSTEM_LEVEL_ENVIRONMENT_VARIABLE
        Can be used for the "level" parameter to any of the EnvironmentVariable APIs.
        See Also:
        Constant Field Values
      • USER_LEVEL_ENVIRONMENT_VARIABLE

        static final int USER_LEVEL_ENVIRONMENT_VARIABLE
        Can be used for the "level" parameter to any of the EnvironmentVariable APIs.
        See Also:
        Constant Field Values
    • Method Detail

      • setEnvironmentVariable

        void setEnvironmentVariable​(java.lang.String variableName,
                                    java.lang.String variableValue)
                             throws ServiceException
        This method is useful to developers when creating a custom bean. Sets the value for a specified environment variable on the target system. This function permanently sets the value of the environment variable in the target system, not just for the duration of the install process. All new processes executed on the target machine after the installation is complete will have the new value for the environment variable once the installer is complete. On some systems, it may be necessary for the end user to logout and login again before the environment variable update(s) takes effect. On some systems, it may be necessary for the user to reboot their machine for the environment variable update(s) to take effect.
        Parameters:
        variableName - - The name of the environment variable
        variableValue - - The value to which the environment variable should be set
        Throws:
        ServiceException
      • setEnvironmentVariable

        void setEnvironmentVariable​(java.lang.String variableName,
                                    java.lang.String variableValue,
                                    int level)
                             throws ServiceException
        This method is useful to developers when creating a custom bean. Sets the value for a specified environment variable on the target system. This function permanently sets the value of the environment variable in the target system, not just for the duration of the install process. All new processes executed on the target machine after the installation is complete will have the new value for the environment variable once the installer in complete. On some systems, it may be necessary for the end user to logout and login again before the environment variable update(s) takes effect. On some systems, it may be necessary for the end user to reboot their machine for the environment variable update(s) to take effect.
        Parameters:
        variableName - - The name of the environment variable
        variableValue - - The value to which the environment variable should be set
        level - - Specifies the level of the environment variable This parameter may be ignored on platforms which do not support the setting of environment variables at different levels (e.g., Win9x).
        Throws:
        ServiceException
      • getEnvironmentVariable

        java.lang.String getEnvironmentVariable​(java.lang.String variableName)
                                         throws ServiceException
        This method is useful to developers when creating a custom bean. Gets the value of the specified environment variable from the target system. The value is fully expanded, i.e., if the environment variable setting includes any nested references to other environment variables, those references are resolved prior to returning the value. Essentially, this method returns the value of the environment variable as the process itself sees the value.
        Parameters:
        variableName - - The name of the variable for which to return a value.
        Returns:
        A string containing the value of the environment variable; null if the environment variable does not exist
        Throws:
        ServiceException
      • getRawEnvironmentVariable

        java.lang.String getRawEnvironmentVariable​(java.lang.String variableName,
                                                   int level)
                                            throws ServiceException
        This method is useful to developers when creating a custom bean. Gets the raw value of the specified environment variable. For operating systems whose environment variable settings are script-controlled, this returns the value of the environment variable from the InstallShield section of the script. For other operating systems, this method acts the same as getEnvironmentVariable . The returned value may contain references to environment variables that are not resolved.
        Parameters:
        variableName - - The name of the variable for which to return a value.
        level - - Specifies the level of the environment variable. This parameter may be ignored on platforms which do not support the setting of environment variables at different levels (e.g., Win9x).
        Returns:
        A string containing the value of the environment variable; null if the environment variable does not exist
        Throws:
        ServiceException
      • deleteEnvironmentVariable

        void deleteEnvironmentVariable​(java.lang.String variableName)
                                throws ServiceException
        This method is useful to developers when creating a custom bean. Deletes the specified environment variable from the target system.
        Parameters:
        variableName - - The name of the environment variable to delete
        Throws:
        ServiceException
      • deleteEnvironmentVariable

        void deleteEnvironmentVariable​(java.lang.String variableName,
                                       int level)
                                throws ServiceException
        This method is useful to developers when creating a custom bean. Deletes the specified environment variable from the target system.
        Parameters:
        variableName - - The name of the environment variable to delete
        level - Specifies the level of the environment variable. This parameter may be ignored on platforms which do not support the setting of environment variables at different levels (e.g., Win9x).
        Throws:
        ServiceException
      • appendEnvironmentVariable

        void appendEnvironmentVariable​(java.lang.String variableName,
                                       java.lang.String variableValue,
                                       java.lang.String delimiter,
                                       int level)
                                throws ServiceException
        This method is useful to developers when creating a custom bean. Appends the variableValue to the end of the current environment variable value. If a delimiter is provided, and the current environment variable is defined and its value is non-blank, the delimiter is placed between the current value and the variableValue being appended.
        Parameters:
        variableName - - The name of the environment variable to modify. It should contain no whitespace.
        variableValue - - The value to append to the environment variable.
        delimiter - - The delimiter to use for separating the existing environment variable value with the new value being appended. Set this to null if no delimiter is desired.
        level - - Specifies the level of the environment variable. This parameter may be ignored on platforms which do not support the setting of environment variables at different levels (e.g., Win9x).
        Throws:
        ServiceException
      • prependEnvironmentVariable

        void prependEnvironmentVariable​(java.lang.String variableName,
                                        java.lang.String variableValue,
                                        java.lang.String delimiter,
                                        int level)
                                 throws ServiceException
        This method is useful to developers when creating a custom bean. Prepends the variableValue to the beginning of the current environment variable value. If a delimiter is provided, and the current environment variable is defined and its value is non-blank, the delimiter is placed between the variableValue being prepended and the current value.
        Parameters:
        variableName - - The name of the environment variable to modify. It should contain no whitespace.
        variableValue - - The value to prepend to the environment variable
        delimiter - - The delimiter to use for separating the existing environment variable value with the new value being prepended. Set this to null if no delimiter is desired.
        level - - Specifies the level of the environment variable. This parameter may be ignored on platforms which do not support the setting of environment variables at different levels (e.g., Win9x).
        Throws:
        ServiceException
      • unAppendEnvironmentVariable

        void unAppendEnvironmentVariable​(java.lang.String variableName,
                                         java.lang.String variableValue,
                                         java.lang.String delimiter,
                                         int level)
                                  throws ServiceException
        This method is useful to developers when creating a custom bean. Removes the specified "appended" value from the environment variable value. It also removes the delimiter if it is found. If the current value of the environment variable is the same as the value to be removed, the environment variable is deleted.
        Parameters:
        variableName - - The name of the environment variable to modify. It should contain no whitespace.
        variableValue - - The appended value to remove from the environment variable.
        delimiter - - The delimiter to use for separating the existing environment variable value with the new value being prepended. Set this to null if no delimiter is desired.
        level - - Specifies the level of the environment variable. This parameter may be ignored on platforms which do not support the setting of environment variables at different levels (e.g., Win9x).
        Throws:
        ServiceException
      • unPrependEnvironmentVariable

        void unPrependEnvironmentVariable​(java.lang.String variableName,
                                          java.lang.String variableValue,
                                          java.lang.String delimiter,
                                          int level)
                                   throws ServiceException
        This method is useful to developers when creating a custom bean. Removes the specified "prepended" value from the environment variable value. It also removes the delimiter if it is found. If the current value of the environment variable is the same as the value to be removed, the environment variable is deleted.
        Parameters:
        variableName - - The name of the environment variable to modify. It should contain no whitespace
        variableValue - - The prepended value to remove from the environment variable
        delimiter - - The delimiter to use for separating the existing environment variable value with the new value being prepended. Set this to null if no delimiter is desired.
        level - - Specifies the level of the environment variable. This parameter may be ignored on platforms which do not support the setting of environment variables at different levels (e.g., Win9x).
        Throws:
        ServiceException
      • getOSServiceLevel

        java.lang.String getOSServiceLevel()
                                    throws ServiceException
        This method is useful to developers when creating a custom bean. Gets the service level of the target system's Windows OS. This can be used by Conditions to determine whether or not a product can be installed given the current service pack level. NOTE : This method should only be used on the Windows Plaform. If used on a different platform, an exception is thrown.
        Returns:
        - The service level of the target system's OS.
        Throws:
        ServiceException
      • addSystemStartupCommand

        void addSystemStartupCommand​(java.lang.String command)
                              throws ServiceException
        Adds a command that runs when the system reboots. The system should not run the command more than once.
        Parameters:
        command - - The command to be run at reboot
        Throws:
        ServiceException
      • removeSystemStartupCommand

        void removeSystemStartupCommand​(java.lang.String command)
                                 throws ServiceException
        Removes a command from the list of commands that run when the system reboots.
        Parameters:
        command - - The command to remove from the list
        Throws:
        ServiceException
      • systemStartupCommands

        java.util.Enumeration systemStartupCommands()
                                             throws ServiceException
        Gets the list of commands to run when the system reboots.
        Returns:
        The list of commands that will run when the system reboots
        Throws:
        ServiceException
      • isRebootRequired

        boolean isRebootRequired()
                          throws ServiceException
        Check if reboot is required by the service architecture.
        Returns:
        true if reboot is required.
        Throws:
        ServiceException
      • setRebootRequired

        void setRebootRequired​(boolean rebootRequired)
                        throws ServiceException
        Set whether or not reboot is required by the service architecture.
        Parameters:
        rebootRequired - True turns on the rebootRequired flag.
        Throws:
        ServiceException
      • deleteFileOnExit

        void deleteFileOnExit​(java.lang.String fileName)
                       throws ServiceException
        This method is useful to developers when creating a custom bean. Adds the file name passed in to the list of deleted files when the system exits. The cleanup method is responsible for actually performing the deletion of these files.
        Parameters:
        fileName - - The absolute path of the file
        Throws:
        ServiceException
      • deleteDirectoryOnExit

        void deleteDirectoryOnExit​(java.lang.String dirName,
                                   boolean recurse)
                            throws ServiceException
        This method is useful to developers when creating a custom bean. Adds the directory name passed in to the list of directories deleted when the system exits. The cleanup method is responsible for actually performing the deletion of these directories.
        Parameters:
        fileName - - The absolute path of the file
        recurse - - "True" causes the directory to be deleted, even if it is not empty
        Throws:
        ServiceException
      • getOSProperties

        java.util.Properties getOSProperties()
                                      throws ServiceException
        This method is useful to developers when creating a custom bean. Returns a Properties object that contains the following information about the target operating system:
        • operating system name (property name "os.name")
        • operating system vendor (property name "os.vendor")
        • operating system version (property name "os.version")
        • operating system architecture (property name "os.arch")
        The above properties can be retrieved from the return value using:
        getProperty(propertyName)
        Throws:
        ServiceException
      • executeProcess

        void executeProcess​(ExecuteProcessSupport execProcSupport,
                            java.util.Properties extendedProperties)
                     throws ServiceException
        This method launches a command in a separate process using a platform specific implementation. The command to execute is described by the ExecuteProcessSupport parameter. If a username and password is set on the ExecuteProcessSupport parameter, the process will be executed on the target system with those user credentials.
        Parameters:
        execProcSupport - - An instance of ExecuteProcessSupport that encapsulates all information necessary to launch an external process or command.
        Throws:
        ServiceException