Class AbstractFilePersistence<I,E extends Exception>

java.lang.Object
org.jppf.persistence.AbstractFilePersistence<I,E>
Type Parameters:
I - the type of objects to persist.
E - the type of exceptions to raise.
Direct Known Subclasses:
DefaultFilePersistence, FileLoadBalancerPersistence

public abstract class AbstractFilePersistence<I,E extends Exception> extends Object
Abstract common superclass for file-based persistence implementations.
Since:
6.0
Author:
Laurent Cohen
  • Field Details

    • DEFAULT_EXTENSION

      protected static final String DEFAULT_EXTENSION
      Default extension for the persisted objects files.
      See Also:
    • TEMP_EXTENSION

      protected static final String TEMP_EXTENSION
      Default extension for temporary files.
      See Also:
    • rootPath

      protected final Path rootPath
      The root directory for this persistence.
  • Constructor Details

    • AbstractFilePersistence

      public AbstractFilePersistence(String... paths)
      Initialize this persistence with the specified path as root directory.
      Parameters:
      paths - the root directory for this persistence.
  • Method Details

    • pathname

      protected String pathname(Path path)
      Get the full path name for the file or directory denoted by the specified path.
      Parameters:
      path - the path for which to get the full name.
      Returns:
      the full path name.
    • checkDirectory

      protected void checkDirectory(Path dir) throws E
      Check the specified directory and create it if it doesn't exist.
      Parameters:
      dir - the directory to check.
      Throws:
      E - if any error occurs.
    • deleteIfEmpty

      protected boolean deleteIfEmpty(Path channelPath) throws E
      Delete the specified directyory if it is empty.
      Parameters:
      channelPath - directory path to delete.
      Returns:
      true if the directory was deleted, false otherwise.
      Throws:
      E - if any error occurs.
    • getSubDir

      protected Path getSubDir(String name)
      Get the directory of witht he psecified name directly under the root.
      Parameters:
      name - the name of the directory to lookup.
      Returns:
      a Path instance.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • convertException

      protected abstract E convertException(Exception e)
      Create the appropriate type of exception.
      Parameters:
      e - the actual exception from which to create the new one.
      Returns:
      an exception of type E.
    • isSameFile

      protected static boolean isSameFile(Path path1, Path path2)
      Determines whether two paths denote the same file.
      Parameters:
      path1 - the first path to check.
      path2 - the second path to check.
      Returns:
      true if the two path represent the same file, false otherwise.
      See Also: