[英]Install4j: common rollback action for multiple scripts or custom actions
I am implementing a silent updater where I do all the version check/ update availability check myself with custom codes and also the installation of the updater after the download. 我正在实现一个无声更新程序,在该程序中,我将使用自定义代码进行所有版本检查/更新可用性检查,并在下载后安装更新程序。 during the installation process I do backups and then perform the update installation and afterwards I perform some tests.
在安装过程中,我先进行备份,然后执行更新安装,然后再执行一些测试。 All these are done using custom action codes and scripts.
所有这些都是使用自定义操作代码和脚本完成的。
Now for custom actions I know I can override
the rollback()
method and for scripts there is this "optional Rollback Script". 现在,对于自定义操作,我知道可以
override
rollback()
方法,而对于脚本,则有此“可选的Rollback Script”。 But is there any action/ abstract class / listener class that I can use commonly for all the codes/scripts? 但是,对于所有代码/脚本,我是否可以共同使用任何动作/抽象类/侦听器类?
You can do this with an event listener: 您可以使用事件侦听器执行此操作:
context.addInstallerEventListener(new InstallerEventListener() {
@Override
public void installerEvent(InstallerEvent event) {
if (event.getType() == EventType.CANCELLING) {
// custom rollback
}
}
});
It will be called before the actions are rolled back. 在回滚操作之前将调用它。 To do something after the actions have been rolled back, replace
EventType.CANCELLING
with EventType.CANCELED
. 要在回滚操作后执行某些操作,请将
EventType.CANCELLING
替换为EventType.CANCELED
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.