Class NativeTarPlatformPackageService
- All Implemented Interfaces:
PlatformPackageService
PlatformPackageService that extracts tar archives using the host's
native tar program.- Since:
- 2.0
- Version:
- 1.1
- Author:
- matt
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.solarnetwork.node.service.PlatformPackageService
PlatformPackageService.PlatformPackage, PlatformPackageService.PlatformPackageResult<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionThe default value of thetarCommandproperty.static final StringThe placeholder string in thesyncCommandfor the destination directory path.static final StringThe placeholder string in thesyncCommandfor the source directory path.Fields inherited from class net.solarnetwork.node.service.support.BasePlatformPackageService
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncleanup()Cleanup any temporary or cached data.protected <T> Callable<PlatformPackageService.PlatformPackageResult<T>> createTask(Path archive, Path baseDirectory, net.solarnetwork.service.ProgressListener<T> progressListener, T context) Create a new task.booleanhandlesPackage(String archiveFileName) Test if this service handles packages with a given name.installNamedPackage(String name, String version, Path baseDirectory, net.solarnetwork.service.ProgressListener<T> progressListener, T context) Install a package.installPackage(Path archive, Path baseDirectory, net.solarnetwork.service.ProgressListener<T> progressListener, T context) Install a package from an archive file.listNamedPackages(String nameFilter, Boolean installedFilter) List named packages, optionally filtering by name and installed status.List upgradable named packages.Refresh named packages.removeNamedPackage(String name, net.solarnetwork.service.ProgressListener<T> progressListener, T context) Remove a named package.voidsetTarCommand(List<String> tarCommand) Set the command and arguments to use for extracting tar resources.upgradeNamedPackages(net.solarnetwork.service.ProgressListener<T> progressListener, T context) Upgrade all installed packages.Methods inherited from class net.solarnetwork.node.service.support.BasePlatformPackageService
getTaskExecutor, performPackageResultTask, performTask, setTaskExecutor, taskExecutor
-
Field Details
-
SOURCE_FILE_PLACEHOLDER
The placeholder string in thesyncCommandfor the source directory path.- See Also:
-
DESTINATION_DIRECTORY_PLACEHOLDER
The placeholder string in thesyncCommandfor the destination directory path.- See Also:
-
DEFAULT_TAR_COMMAND
The default value of thetarCommandproperty.The tar command is expected to print the names of the files as it extracts them, which is usually done with a -v argument.
-
-
Constructor Details
-
NativeTarPlatformPackageService
public NativeTarPlatformPackageService()Default constructor.
-
-
Method Details
-
handlesPackage
Description copied from interface:PlatformPackageServiceTest if this service handles packages with a given name.- Parameters:
archiveFileName- the name of the package archive file; a file extension might be used to determine the type of package the name represents- Returns:
- true if the archive file name is supported by this service
-
installPackage
public <T> Future<PlatformPackageService.PlatformPackageResult<T>> installPackage(Path archive, Path baseDirectory, net.solarnetwork.service.ProgressListener<T> progressListener, T context) Description copied from interface:PlatformPackageServiceInstall a package from an archive file.- Type Parameters:
T- the context object type- Parameters:
archive- the package to extract and installbaseDirectory- a "base" directory to resolve relative file paths againstprogressListener- an optional listener of the progress of extracting the packagecontext- a context object to pass toprogressListenerand provide in the result; may be null- Returns:
- a future for the package installation results
-
createTask
protected <T> Callable<PlatformPackageService.PlatformPackageResult<T>> createTask(Path archive, Path baseDirectory, net.solarnetwork.service.ProgressListener<T> progressListener, T context) Create a new task.- Type Parameters:
T- the task type- Parameters:
archive- the archivebaseDirectory- the base directoryprogressListener- a progress listenercontext- the context- Returns:
- the task
-
listNamedPackages
public Future<Iterable<PlatformPackageService.PlatformPackage>> listNamedPackages(String nameFilter, Boolean installedFilter) Description copied from interface:PlatformPackageServiceList named packages, optionally filtering by name and installed status.- Parameters:
nameFilter- a regular expression to filter packages by, or null to include everythinginstalledFilter- true to include only installed packages, false to exclude installed packages, or null to include everything- Returns:
- the matching packages, never null
-
listUpgradableNamedPackages
Description copied from interface:PlatformPackageServiceList upgradable named packages.- Returns:
- the upgradable packages, never null
-
refreshNamedPackages
Description copied from interface:PlatformPackageServiceRefresh named packages.- Returns:
- the task completion status
-
cleanup
Description copied from interface:PlatformPackageServiceCleanup any temporary or cached data.- Returns:
- the task completion status
-
installNamedPackage
public <T> Future<PlatformPackageService.PlatformPackageResult<T>> installNamedPackage(String name, String version, Path baseDirectory, net.solarnetwork.service.ProgressListener<T> progressListener, T context) Description copied from interface:PlatformPackageServiceInstall a package.This method is used to install named packages that are "available" to be installed, i.e. one that is returned from the
PlatformPackageService.listNamedPackages(String, Boolean)method when false is passed. The package might have to be downloaded from a remote package repository and then installed.- Type Parameters:
T- the context object type- Parameters:
name- the package name to installversion- the package version to install, or null for the highest available versionbaseDirectory- a "base" directory to resolve relative file paths againstprogressListener- an optional listener of the progress of extracting the packagecontext- a context object to pass toprogressListenerand provide in the result; may be null- Returns:
- a future for the package installation results
-
removeNamedPackage
public <T> Future<PlatformPackageService.PlatformPackageResult<T>> removeNamedPackage(String name, net.solarnetwork.service.ProgressListener<T> progressListener, T context) Description copied from interface:PlatformPackageServiceRemove a named package.This method is used to remove named packages that are currently installed.
- Type Parameters:
T- the context object type- Parameters:
name- the package name to installprogressListener- an optional listener of the progress of extracting the packagecontext- a context object to pass toprogressListenerand provide in the result; may be null- Returns:
- a future for the package installation results
-
upgradeNamedPackages
public <T> Future<PlatformPackageService.PlatformPackageResult<T>> upgradeNamedPackages(net.solarnetwork.service.ProgressListener<T> progressListener, T context) Description copied from interface:PlatformPackageServiceUpgrade all installed packages.This method is used to upgrade named packages to the highest available versions.
- Type Parameters:
T- the context object type- Parameters:
progressListener- an optional listener of the progress of extracting the packagecontext- a context object to pass toprogressListenerand provide in the result; may be null- Returns:
- a future for the package installation results
-
setTarCommand
Set the command and arguments to use for extracting tar resources.The arguments support __SOURCE_FILE__ and __DEST_DIR__ placeholders that will be replaced by the input tar file path and the value of the
destinationPathproperty.- Parameters:
tarCommand- the OS tar command to use
-