Class AbstractPersister

java.lang.Object
net.sodacan.core.persist.AbstractPersister
All Implemented Interfaces:
Persister
Direct Known Subclasses:
FilePersister, MemoryPersister, RocksPersister

public abstract class AbstractPersister extends Object implements Persister
This abstract class provides two services to concrete subclasses: First, it stores the configuration and actorId of the Actor instance for which it applies. Second, it provides a consistent file naming service in the case of a persister that uses disk file(s). A Subclass is not required to use the naming service(s).
  • Constructor Details

    • AbstractPersister

      public AbstractPersister(Config config, ActorId actorId)
  • Method Details

    • getConfig

      public Config getConfig()
    • getActorId

      public ActorId getActorId()
    • makeFile

      protected File makeFile(String extension)
      Files are organized by ActorGroup, type of actor, and actor id. The root folder is assumes to exist. This method creates the entire hierarchy of folders as needed and returns a file handle to the file.
      Returns:
      A File handle
    • makeFolder

      protected File makeFolder()
      This method return a file handle to folder assigned to the specific actorId. This method is used when the persister requires a folder into which possibly multiple files will be placed. This method creates the entire hierarchy of folders as needed and returns a file handle to the target folder.
      Returns:
      A File handle to the folder created
    • makeTypeFolder

      protected File makeTypeFolder()
      This method return a file handle to the ActorType directory within the specified ActorGroup directory within the specified Host directory within the specified root folder creating directories that do not exist. This method is already called by the makeFolder and makeFile methods. Therefore, it should normally not be called directly by a persister but might be overriden to provide a custom directory structure.
      Returns:
      A File handle to the ActorType directory