Class CustomCodeAction


  • public abstract class CustomCodeAction
    extends java.lang.Object

    The CustomCodeAction class is designed to allow developers to extend InstallAnywhere's core functionality by creating custom actions that can be integrated with InstallAnywhere installers.

    Actions that extend CustomCodeAction may also implement an uninstall(). If an action is run by being placed in the Install sequence in InstallAnywhere's designer the uninstall method will be run as part of the Resource Uninstall step of the uninstaller (the portion of uninstall when files, folders and other resources are uninstalled. Depending on settings in the IA Designer, the uninstall method may run either before or after uninstallation of those resources. Actions run as part of IA's Pre-Install and Post-Install sequnces will run only the install() methods, and will not run uninstall() methods at uninstall time. Actions run as part of IA's Pre-Uninstall and Post-Install sequences will run only the uninstall() methods, and will not run install() methods at install time.

    There are several services and classes that can be used with and help classes that extend CustomCodeAction to provide additional functionality for an installer.

    See Also:
    InstallerProxy, UninstallerProxy, InstallerResources, SimpleRegistryManager
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static InstallerProxy installerProxy
      This class variable, available at install-time, provides access to designer-specified resources, system and user-defined variables, and international resources.
      protected static UninstallerProxy uninstallerProxy
      This class variable, available at uninstall-time, provides access to designer-specified resources, system and user-defined variables, and international resources.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      long getEstimatedTimeToInstall​(InstallerProxy ip)
      This method should return the estimated time, in tenths (1/10) of seconds, to complete the install operation, given the action's current state.
      long getEstimatedTimeToUninstall​(UninstallerProxy ip)
      This method should return the estimated time, in tenths (1/10) of seconds, to complete the uninstall operation, given the action's current state.
      abstract java.lang.String getInstallStatusMessage()
      If this action is included in the "Install" task of the advanced designer, the string that this method returns will be displayed in the "Installing..." status label that appears above the installer's progress bar while the action is being executed.
      abstract java.lang.String getUninstallStatusMessage()
      If this action implements the uninstall() method and meets the requirements to be executed during the execution of the uninstaller, the string that this method returns will be displayed by the uninstaller during the execution of this action.
      abstract void install​(InstallerProxy ip)
      The install() method is called at install-time.
      java.util.Properties loadProperties​(java.io.InputStream in)  
      static void setInstallerProxy​(InstallerProxy ip)
      This method sets the InstallerProxy variable to make it available for use in the custom code action.
      static void setUninstallerProxy​(UninstallerProxy uip)
      This method sets the UninstallerProxy variable to make it available for use in the custom code action.
      abstract void uninstall​(UninstallerProxy up)
      The uninstall() method is called at uninstall-time before any files, folders or other installation actions are uninstalled.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • installerProxy

        protected static InstallerProxy installerProxy

        This class variable, available at install-time, provides access to designer-specified resources, system and user-defined variables, and international resources.

        As a class variable, this instance is available to all methods of a CustomCodeAction implementation, not just the install() method which receives an instance of InstallerProxy as a parameter.

        This variable has a null value during uninstall.

        See Also:
        InstallerProxy
      • uninstallerProxy

        protected static UninstallerProxy uninstallerProxy

        This class variable, available at uninstall-time, provides access to designer-specified resources, system and user-defined variables, and international resources.

        As a class variable, this instance is available to all methods of a CustomCodeAction implementation, not just the uninstall() method which receives an instance of UninstallerProxy as a parameter.

        This variable has a null value during install.

        See Also:
        UninstallerProxy
    • Constructor Detail

      • CustomCodeAction

        public CustomCodeAction()
    • Method Detail

      • setInstallerProxy

        public static void setInstallerProxy​(InstallerProxy ip)

        This method sets the InstallerProxy variable to make it available for use in the custom code action. This method should not be called or overridden by CustomCodeAction subclasses.

        Parameters:
        ip - Used to initialize the installerProxy class variable, provides access to designer-specified resources, system and user-defined variables, and international resources.
        See Also:
        InstallerProxy
      • setUninstallerProxy

        public static void setUninstallerProxy​(UninstallerProxy uip)

        This method sets the UninstallerProxy variable to make it available for use in the custom code action. This method should not be called or overridden by CustomCodeAction subclasses.

        Parameters:
        ip - Used to initialize the uninstallerProxy class variable, provides access to designer-specified resources, system and user-defined variables, and international resources.
        See Also:
        UninstallerProxy
      • install

        public abstract void install​(InstallerProxy ip)
                              throws InstallException

        The install() method is called at install-time. The InstallerProxy parameter provides methods to access information in the installer, set status, control flow, and save data to be retrieved during uninstall.

        The install method will be called if the action that called this CustomCodeAction was in the "Install" task of the InstallAnywhere advanced designer. This method will also be called during uninstall if the action that executed this CustomCodeAction was in either the "Pre-Install", or "Post-Install" tasks of the advanced designer.

        To signify the occurence of an error in the custom code action, an InstallException may thrown. InstallException is an abstract class. It has two concrete subclasses, FatalInstallException and NonfatalInstallException.

        If these exceptions are thrown, an error will be logged in the end user's install log and InstallAnywhere will continue with the installation. To force InstallAnywhere to exit and abort the installation, use InstallerProxy.abortInstallation().

        To report errors in the end-user's install log without throwing an InstallException, use the CustomError service.

        Parameters:
        ip - Provides access to designer-specified resources, system and user-defined variables, and international resources.
        Throws:
        InstallException
        See Also:
        InstallerProxy, InstallerProxy.abortInstallation(int), NonfatalInstallException, FatalInstallException, CustomError
      • uninstall

        public abstract void uninstall​(UninstallerProxy up)
                                throws InstallException

        The uninstall() method is called at uninstall-time before any files, folders or other installation actions are uninstalled. The UninstallerProxy parameter provides methods to access information written to the installation log by this same action during install

        The uninstall method will be called if the action that called this CustomCodeAction was in the "Install" task of the InstallAnywhere advanced designer. This method will also be called during uninstall if the action that executed this CustomCodeAction was in either the "Pre-Uninstall", or "Post-Uninstall" tasks of the advanced designer.

        To signify the occurence of an error in the custom code action, an InstallException may thrown. InstallException is an abstract class. It has two concrete subclasses, FatalInstallException and NonfatalInstallException.

        If these exceptions are thrown, InstallAnywhere will continue with the the uninstall. At this time, there is no mechanism for errors in custom code actions during the uninstall to be reported to the user.

        Parameters:
        up - Provides access to designer-specified resources, system and user-defined variables, and international resources.
        Throws:
        InstallException
        See Also:
        UninstallerProxy
      • getInstallStatusMessage

        public abstract java.lang.String getInstallStatusMessage()

        If this action is included in the "Install" task of the advanced designer, the string that this method returns will be displayed in the "Installing..." status label that appears above the installer's progress bar while the action is being executed. The method will be called during the Resource Uninstall step of the uninstall sequence, either before or after uninstalling resources, depending on customizer settings.

        If this action is included in the "Uninstall" task, the uninstall() method called for this action, but the install() method will not be called.
        Returns:
        the String to be displayed in the "Installing..." status label.
      • getUninstallStatusMessage

        public abstract java.lang.String getUninstallStatusMessage()

        If this action implements the uninstall() method and meets the requirements to be executed during the execution of the uninstaller, the string that this method returns will be displayed by the uninstaller during the execution of this action.

        Returns:
        the String to be displayed by the uninstaller.
      • getEstimatedTimeToInstall

        public long getEstimatedTimeToInstall​(InstallerProxy ip)
        This method should return the estimated time, in tenths (1/10) of seconds, to complete the install operation, given the action's current state. This value is used to weigh the progress of multiple actions during installation. This value is only an estimate and does not have to be accurate to be effective.

        For example, it could take one action several seconds to install a set of files. It could take another action only a fraction of a second to install and configure a desktop icon. If both action's progress were weighted equally, e.g., each contributed 50% to the overall progress, the progress bar would move steadily up to the 50% mark during the files installation and then jump immediately to 100% during the desktop icon installation. Even rough estimates of the action's time to install allows progress to be charted more smoothly.

        NOTE: Actions which claim to have a particular estimated time must utilize the progress api's within the proxy objects at install/uninstall time to account for their full progress. Failure to do so will result in improper progress reporting within the runtime GUI.

        Parameters:
        ip - Provides access to designer-specified resources, system and user-defined variables, and international resources.
        Returns:
        The estimated time to install this action (as described above).
        See Also:
        InstallerProxy
      • getEstimatedTimeToUninstall

        public long getEstimatedTimeToUninstall​(UninstallerProxy ip)
        This method should return the estimated time, in tenths (1/10) of seconds, to complete the uninstall operation, given the action's current state. This value is used to weigh the progress of multiple action during uninstallation. This value is only an estimate, and does not have to be accurate to be effective.

        NOTE: Actions which claim to have a particular estimated time must utilize the progress api's within the proxy objects at install/uninstall time to account for their full progress. Failure to do so will result in improper progress reporting within the runtime GUI.

        Parameters:
        up - Provides access to designer-specified resources, system and user-defined variables, and international resources.
        Returns:
        The estimated time to uninstall this action (as described above).
        See Also:
        UninstallerProxy
      • loadProperties

        public java.util.Properties loadProperties​(java.io.InputStream in)
                                            throws java.io.IOException
        Throws:
        java.io.IOException