public class UpdateChecker
extends java.lang.Object
In order to use this class in your application, please include resource/i4jruntime.jar
from your
install4j installation into your class path. You do not need to distribute this file
along with your application, install4j will do this automatically for you.
UpdateDescriptor
Constructor and Description |
---|
UpdateChecker() |
Modifier and Type | Method and Description |
---|---|
static void |
executeScheduledUpdate(java.util.List<java.lang.String> updaterArguments,
boolean restartLauncher,
java.util.List<java.lang.String> launcherArguments,
java.lang.Runnable shutdownRunnable)
If an update is scheduled for installation execute the update installer and shutdown the current launcher.
|
static void |
executeScheduledUpdate(java.util.List<java.lang.String> updaterArguments,
boolean restartLauncher,
java.lang.Runnable shutdownRunnable)
If an update is scheduled for installation execute the update installer and shutdown the current launcher.
|
static UpdateDescriptor |
getUpdateDescriptor(java.lang.String urlSpec,
ApplicationDisplayMode displayMode)
Convenience method for
getUpdateDescriptor(UpdateCheckRequest) . |
static UpdateDescriptor |
getUpdateDescriptor(java.lang.String urlSpec,
ApplicationDisplayMode displayMode,
ErrorHandlingCallback errorHandlingCallback)
Convenience method for
getUpdateDescriptor(UpdateCheckRequest) . |
static UpdateDescriptor |
getUpdateDescriptor(UpdateCheckRequest updateCheckRequest)
Download an
updates.xml file programatically from a given URL and returns an
UpdateDescriptor instance. |
static boolean |
isUpdateScheduled()
Checks if the "Schedule update installation" action has registered a downloaded update for installation.
|
static boolean |
isVersionGreaterThan(java.lang.String expectedHigherVersion,
java.lang.String expectedLowerVersion)
Compares two version strings and checks if the first version is greater than the second version.
|
static boolean |
isVersionLessThanOrEqual(java.lang.String expectedLowerVersion,
java.lang.String expectedHigherVersion)
Compares two version strings and checks if the first version is lower or equal than the second version.
|
public static UpdateDescriptor getUpdateDescriptor(java.lang.String urlSpec, ApplicationDisplayMode displayMode) throws UserCanceledException, java.io.IOException
getUpdateDescriptor(UpdateCheckRequest)
.urlSpec
- see UpdateCheckRequest.urlSpec(String)
displayMode
- see UpdateCheckRequest.applicationDisplayMode(ApplicationDisplayMode)
UserCanceledException
- if the user cancels the proxy dialogjava.io.IOException
- if the download failspublic static UpdateDescriptor getUpdateDescriptor(java.lang.String urlSpec, ApplicationDisplayMode displayMode, ErrorHandlingCallback errorHandlingCallback) throws UserCanceledException, java.io.IOException
getUpdateDescriptor(UpdateCheckRequest)
.urlSpec
- see UpdateCheckRequest.urlSpec(String)
displayMode
- see UpdateCheckRequest.applicationDisplayMode(ApplicationDisplayMode)
errorHandlingCallback
- see UpdateCheckRequest.errorHandlingCallback(ErrorHandlingCallback)
UserCanceledException
- if the user cancels the proxy dialogjava.io.IOException
- if the download failspublic static UpdateDescriptor getUpdateDescriptor(UpdateCheckRequest updateCheckRequest) throws UserCanceledException, java.io.IOException
updates.xml
file programatically from a given URL and returns an
UpdateDescriptor
instance. The UpdateCheckRequest
specifies the URL and other connection options.updateCheckRequest
- the update check requestUserCanceledException
- if the user cancels the proxy dialogjava.io.IOException
- if the download failspublic static boolean isUpdateScheduled()
true
if scheduled and ready to be executedpublic static void executeScheduledUpdate(java.util.List<java.lang.String> updaterArguments, boolean restartLauncher, java.lang.Runnable shutdownRunnable)
Equivalent to calling executeScheduledUpdate(List, boolean, List, Runnable)
with null for the launcherArguments parameter
updaterArguments
- updaterArguments to be passed to the updater.restartLauncher
- if true a GUI or a console launcher will be restarted after the installation. If called from a service launcher the
installer must take care of starting the service again. It can use context.getBooleanVariable("sys.automaticUpdate") if restart should be done conditionally.shutdownRunnable
- if you want to invoke a custom routine for shutting down the current JVM, you can pass in a Runnable. Otherwise, System.exit(0) will be called.
If you pass in a Runnable. you must call System.exit at the end of your shutdown procedure.public static void executeScheduledUpdate(java.util.List<java.lang.String> updaterArguments, boolean restartLauncher, java.util.List<java.lang.String> launcherArguments, java.lang.Runnable shutdownRunnable)
updaterArguments
- updaterArguments to be passed to the updater.restartLauncher
- if true a GUI or a console launcher will be restarted after the installation. If called from a service launcher the
installer must take care of starting the service again. It can use context.getBooleanVariable("sys.automaticUpdate") if restart should be done conditionally.launcherArguments
- if restartLauncher is true and this method is called within a GUI or a console launcher, the given arguments will be passed to the restarted launchershutdownRunnable
- if you want to invoke a custom routine for shutting down the current JVM, you can pass in a Runnable. Otherwise, System.exit(0) will be called.
If you pass in a Runnable. you must call System.exit at the end of your shutdown procedure.public static boolean isVersionLessThanOrEqual(java.lang.String expectedLowerVersion, java.lang.String expectedHigherVersion)
UpdateDescriptor.getPossibleUpdateEntry()
and
UpdateDescriptorEntry.checkVersionCompatible(String)
to check the compliance with the range of
minimum and maximum updatable version.expectedLowerVersion
- the version that is expected to be lower or equalexpectedHigherVersion
- the version that is expected to be higher or equaltrue
if expectedHigherVersion
is higher or equal than expectedLowerVersion
public static boolean isVersionGreaterThan(java.lang.String expectedHigherVersion, java.lang.String expectedLowerVersion)
UpdateDescriptor.getPossibleUpdateEntry()
and
UpdateDescriptorEntry.checkVersionCompatible(String)
to check if a new version is greater
than the installed version.expectedHigherVersion
- the version that is expected to be higherexpectedLowerVersion
- the version that is expected to be lowertrue
if expectedHigherVersion
is higher than installedVersion