install4j API

com.install4j.api
Class InstallAction

java.lang.Object
  extended by com.install4j.api.CustomAction
      extended by com.install4j.api.InstallAction

public abstract class InstallAction
extends CustomAction

All install actions must be derived from this class. You have to override the appropriate methods and provide a public constructor with no arguments.

Of the three perform* methods, only one is called for a particular installation.

The different environment of these three perform* methods is apparent in the different parameters. While performAction gets an InstallerWizardContext and a ProgressInterface, performUnattendedAction only gets a InstallerContext. Finally, performFirstRunAction is not passed any arguments. You'll have to code your action accordingly for any of the cases that you support.

If you don't produce any archive media files, you can ignore performFirstRunAction. By default, unattended installations are not enabled, so you can choose to ignore performUnattendedAction. If you only produce archive installers, you can ignore performAction, too.

If necessary, you can override the two rollback* methods which correspond to the perform* methods.

In the installer wizard, the user can cancel the installation. If your custom action takes a long time, you should override the cancel method to let your performAction method know that it should return as soon as possible. You can do that by setting a flag in cancel that is checked regulary by your performAction method.

Author:
ej-technologies GmbH

Constructor Summary
InstallAction()
           
 
Method Summary
 void cancel()
          Override this method to react to the user canceling the installation.
 boolean performAction(InstallerWizardContext context, ProgressInterface progressInterface)
          Override this method to perform the custom action in the installation wizard.
 boolean performFirstRunAction()
          Override this method to perform the custom action for archive media files.
 boolean performUnattendedAction(InstallerContext context)
          Override this method to perform the custom action for unattended installations.
 void rollback(InstallerWizardContext context, ProgressInterface progressInterface)
          Override this method to perform a rollback of the performAction method.
 void rollbackUnattended(InstallerContext context)
          Override this method to perform a rollback of the performUnattendedAction method.
 
Methods inherited from class com.install4j.api.CustomAction
getPercentOfTotalInstallation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InstallAction

public InstallAction()
Method Detail

performAction

public boolean performAction(InstallerWizardContext context,
                             ProgressInterface progressInterface)
                      throws UserCanceledException
Override this method to perform the custom action in the installation wizard.

Note: For unattended installations, the performUnattendedAction method is called instead.

Parameters:
context - the context of the installation.
progressInterface - an interface to display progress and messages.
Returns:
should return true, if successful. If it returns false, the installation will be aborted.
Throws:
UserCanceledException - thrown e.g. by file installation methods. You can let these exceptions pass through, they will be handled by the framework.

performUnattendedAction

public boolean performUnattendedAction(InstallerContext context)
Override this method to perform the custom action for unattended installations. By default, unattended installations are not enabled. You have to enable them on the "Installer features" tab in the "Installer" section of the install4j GUI.

Parameters:
context - the context of the installation.
Returns:
should return true, if successful. If it returns false, the installation will be aborted.

performFirstRunAction

public boolean performFirstRunAction()
Override this method to perform the custom action for archive media files. For archive media files without a GUI installer, custom actions are run once when the users starts any of the generated launchers for the first time.

Returns:
should return true, if successful. If it returns false, the installation will be aborted.

rollback

public void rollback(InstallerWizardContext context,
                     ProgressInterface progressInterface)
Override this method to perform a rollback of the performAction method. This method is only called if the performAction methods has already been called and the installation is canceled by the user or if the installation fails for some reason.

Parameters:
context - the context of the installation.
progressInterface - an interface to display progress and messages.

rollbackUnattended

public void rollbackUnattended(InstallerContext context)
Override this method to perform a rollback of the performUnattendedAction method. This method is only called if the performUnattendedAction methods has already been called and the installation fails for some reason.

Parameters:
context - the context of the installation.

cancel

public void cancel()
Override this method to react to the user canceling the installation. The framework calls this method if the user cancels the installation while this action is performed. If your action takes more than a few hundred milliseconds, you should set a flag and try to return from performAction as soon as possible. This method is called on a different thread than the one where performAction is runnnig.


install4j API