Interface CancelButtonRegister
-
public interface CancelButtonRegister
This interface provides a cancel button registration service that can be requested by a custom code action. Through this service, the action can register a cancel button handler, which will be executed by InstallAnywhere installer runtime if the install is cancelled. 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.
The
CancelButtonRegister
object is obtained through theInstallerProxy
,CustomCodePanelProxy
, andCustomCodeConsoleProxy
objects by a request for theCancelButtonRegister
class. This is an example of how cancel button handler registration is implemented:
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import com.zerog.ia.api.pub.CustomCodeAction;
import com.zerog.ia.api.pub.FatalInstallException;
import com.zerog.ia.api.pub.InstallException;
import com.zerog.ia.api.pub.InstallerProxy;
import com.zerog.ia.api.pub.CancelButtonHandler;
import com.zerog.ia.api.pub.CancelButtonRegister;
import com.zerog.ia.api.pub.UninstallerProxy;
public class AutomaticCancelAction extends CustomCodeAction {
private static final String FILE_NAME = "installed-file.txt";
public void install(InstallerProxy proxy) throws InstallException {
registerCancelButtonHandler(proxy);
installFile(proxy);
}
private void installFile(InstallerProxy proxy) throws FatalInstallException {
String installDir = proxy.substitute("$USER_INSTALL_DIR$");
try {
FileOutputStream stream = new FileOutputStream(new File(installDir,
FILE_NAME));
try {
stream.write("contents".getBytes("UTF-8"));
} finally {
stream.close();
}
} catch (IOException e) {
throw new FatalInstallException(e.getMessage());
}
}
private void registerCancelButtonHandler(InstallerProxy proxy) {
CancelButtonRegister register = (CancelButtonRegister) proxy
.getService(CancelButtonRegister.class);
register.addHandler(new CancelButtonHandler() {
public void installCancelled(InstallerProxy proxy) {
String installDir = proxy.substitute("$USER_INSTALL_DIR$");
File installedFile = new File(installDir, FILE_NAME);
if (installedFile.exists()) {
installedFile.delete();
}
}
});
}
// TODO Add other required methods
}
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addHandler(CancelButtonHandler handler)
-
-
-
Method Detail
-
addHandler
void addHandler(CancelButtonHandler handler)
-
-