Interface CancelButtonHandler


  • public interface CancelButtonHandler

    This interface allows a installation cancel behavior to be defined for custom code action. Cancel Button handler must attempt to stop the customcode execution process immediately so that the installation cancel action is done promptly during the execution of customcode. The rollback handler waits for the current custom action to stop executing before the rollback handler is called. However the cancel handler triggers immediately on cancellation of the installation. This is especially useful, when the current custom action being executed takes up a long time.

    When an custom code action implements CancelButtonHandler interface, the action will be automatically registered and will be called when installation cancel event is triggered via cancel button. This is an example of how CancelButtonHandler is implemented:


    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;

    import com.zerog.ia.api.pub.CancelButtonHandler;
    import com.zerog.ia.api.pub.CustomCodeAction;
    import com.zerog.ia.api.pub.InstallException;
    import com.zerog.ia.api.pub.InstallerProxy;
    import com.zerog.ia.api.pub.UninstallerProxy;

    public class InstallCancelAction extends CustomCodeAction implements CancelButtonHandler {
       private boolean allDone = true;

       public void install(InstallerProxy proxy) throws InstallException {
          while (allDone) {
             System.out.println("Customcode execution in progress...");
             try {
                Thread.sleep(2000);
             } catch (InterruptedException e) {
                e.printStackTrace();
             }
          }
       }

       public void installCancelled(InstallerProxy installer) throws InstallException {
          System.out.println("*********** In the CANCEL BUTTON handler **************");
          System.out.println("Execution of custom code interrupted. Stopping the custom code");
          allDone = false;
       }

       public void uninstall(UninstallerProxy uninstallerproxy)throws InstallException {
       }

       public String getInstallStatusMessage() {
          return null;
       }

       public String getUninstallStatusMessage() {
          return null;
       }

       // TODO: Add other required methods
    }