Class NativeTarPlatformPackageService

java.lang.Object
net.solarnetwork.node.service.support.BasePlatformPackageService
net.solarnetwork.node.service.support.NativeTarPlatformPackageService
All Implemented Interfaces:
PlatformPackageService

public class NativeTarPlatformPackageService extends BasePlatformPackageService
PlatformPackageService that extracts tar archives using the host's native tar program.
Since:
2.0
Version:
1.0
Author:
matt
  • Field Details

    • SOURCE_FILE_PLACEHOLDER

      public static final String SOURCE_FILE_PLACEHOLDER
      The placeholder string in the syncCommand for the source directory path.
      See Also:
    • DESTINATION_DIRECTORY_PLACEHOLDER

      public static final String DESTINATION_DIRECTORY_PLACEHOLDER
      The placeholder string in the syncCommand for the destination directory path.
      See Also:
    • DEFAULT_TAR_COMMAND

      public static final List<String> DEFAULT_TAR_COMMAND
      The default value of the tarCommand property.

      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()
  • Method Details

    • handlesPackage

      public boolean handlesPackage(String archiveFileName)
      Description copied from interface: PlatformPackageService
      Test 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: PlatformPackageService
      Install a package from an archive file.
      Type Parameters:
      T - the context object type
      Parameters:
      archive - the package to extract and install
      baseDirectory - a "base" directory to resolve relative file paths against
      progressListener - an optional listener of the progress of extracting the package
      context - a context object to pass to progressListener and 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 archive
      baseDirectory - the base directory
      progressListener - a progress listener
      context - the context
      Returns:
      the task
    • listNamedPackages

      public Future<Iterable<PlatformPackageService.PlatformPackage>> listNamedPackages(String nameFilter, Boolean installedFilter)
      Description copied from interface: PlatformPackageService
      List named packages, optionally filtering by name and installed status.
      Parameters:
      nameFilter - a regular expression to filter packages by, or null to include everything
      installedFilter - true to include only installed packages, false to exclude installed packages, or null to include everything
      Returns:
      the matching packages, never null
    • refreshNamedPackages

      public Future<Boolean> refreshNamedPackages()
      Description copied from interface: PlatformPackageService
      Refresh named packages.
      Returns:
      the task completion status
    • cleanup

      public Future<Boolean> cleanup()
      Description copied from interface: PlatformPackageService
      Cleanup 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: PlatformPackageService
      Install 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 install
      version - the package version to install, or null for the highest available version
      baseDirectory - a "base" directory to resolve relative file paths against
      progressListener - an optional listener of the progress of extracting the package
      context - a context object to pass to progressListener and 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: PlatformPackageService
      Remove 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 install
      progressListener - an optional listener of the progress of extracting the package
      context - a context object to pass to progressListener and 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: PlatformPackageService
      Upgrade 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 package
      context - a context object to pass to progressListener and provide in the result; may be null
      Returns:
      a future for the package installation results
    • setTarCommand

      public void setTarCommand(List<String> tarCommand)
      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 destinationPath property.

      Parameters:
      tarCommand - the OS tar command to use