public final class VersionChecker extends Object implements Runnable
Modifier and Type | Field and Description |
---|---|
private static String |
BIN_DIRECTORY_AND_JAVA
bin subdirectory and java executable.
|
private boolean |
downloadDone
Indicate if the download is completed.
|
private String |
downloadedJar
Name of the downloaded jar.
|
private String |
gitHubRepository
GitHub repository.
|
private String |
gitHubUser
Root URL of the GitHub project to update.
|
private static String |
JAR_ARGUMENT
Jar argument for java reloading.
|
private static String |
JAR_EXTENSION
Jar extension.
|
private String |
jarWithDependenciesSuffix
Suffix of the full jar including all dependencies.
|
private static String |
JAVA_HOME_PROPERTY
Java home property.
|
private static org.slf4j.ext.XLogger |
LOG
SLF4J XLogger.
|
private String |
mavenArtifactId
Maven artifact identifier.
|
private static int |
ONE_MEGABYTE
Precalculated one megabyte for indicating download size.
|
private static String |
TARGET_DIRECTORY
Target directory in zipball releases.
|
private static String |
TMP_EXTENSION
Tmp extension.
|
private boolean |
versionCheckerDisabled
Indicate if the version checker is disabled.
|
private static String |
WINDOWS_EXE_EXTENSION
Executable extension on Windows.
|
Constructor and Description |
---|
VersionChecker(String gitHubUserArg,
String gitHubRepositoryArg,
String mavenArtifactIdArg,
String jarWithDependenciesSuffixArg)
Initialize the version checker with jar artifact and suffixnames and path to GitHub.
|
Modifier and Type | Method and Description |
---|---|
void |
cleanOldAndTemporaryJar()
Clean the old jar and any existing temporary file.
|
private String |
currentJar()
Return the current executed jar.
|
private static void |
deleteJar(Path jarFileToDelete)
Delete a jar file.
|
private static void |
downloadFile(InputStream inputStream,
String destinationFile)
Download a file/URL and write it to a destination file.
|
private boolean |
findAndDownloadReleaseJar(org.eclipse.egit.github.core.RepositoryTag release,
boolean withDependenciesSuffix)
Find a jar in release and if it is a newer version, ask to download it.
|
private static String |
getJavaExecutable()
Get the java executable.
|
boolean |
isDownloadDone()
Get the download status.
|
boolean |
isversionCheckerDisabled()
Get the state of the version checker.
|
void |
resetVersionCheckerDisabled()
Enable the version checker.
|
boolean |
restart()
Restart the RunDeck monitor and use the newer jar file.
|
void |
run()
Background thread launched to check the version on GitHub.
|
private static final org.slf4j.ext.XLogger LOG
private static final int ONE_MEGABYTE
private static final String JAR_EXTENSION
private static final String TMP_EXTENSION
private static final String WINDOWS_EXE_EXTENSION
private static final String JAVA_HOME_PROPERTY
private static final String TARGET_DIRECTORY
private static final String BIN_DIRECTORY_AND_JAVA
private static final String JAR_ARGUMENT
private final String gitHubUser
private final String gitHubRepository
private final String mavenArtifactId
private final String jarWithDependenciesSuffix
private boolean downloadDone
private boolean versionCheckerDisabled
private String downloadedJar
public VersionChecker(String gitHubUserArg, String gitHubRepositoryArg, String mavenArtifactIdArg, String jarWithDependenciesSuffixArg)
gitHubUserArg
- GitHub usergitHubRepositoryArg
- GitHub repositorymavenArtifactIdArg
- maven artifact idjarWithDependenciesSuffixArg
- suffix of the full jar including all dependenciespublic void run()
private boolean findAndDownloadReleaseJar(org.eclipse.egit.github.core.RepositoryTag release, boolean withDependenciesSuffix) throws IOException
release
- GitHub last release to usewithDependenciesSuffix
- indicate if the jar to download have a dependencies suffixIOException
- in case of reading errorpublic boolean restart()
public void cleanOldAndTemporaryJar()
private static void deleteJar(Path jarFileToDelete)
jarFileToDelete
- file to deleteprivate String currentJar()
public boolean isDownloadDone()
public void resetVersionCheckerDisabled()
public boolean isversionCheckerDisabled()
private static void downloadFile(InputStream inputStream, String destinationFile) throws IOException
inputStream
- source streamdestinationFile
- destination fileIOException
- in case of copy errorprivate static String getJavaExecutable() throws NoSuchFileException
NoSuchFileException
- if the java executable is not foundCopyright © 2013–2015. All rights reserved.