Class OSSStorageManager

java.lang.Object
com.oss.storage.OSSStorageManager
All Implemented Interfaces:
StorageManager

public class OSSStorageManager extends Object implements StorageManager
This class implements the default storage manager that uses a disk file to store the content octets of the storage. Each allocation request results in a temporary file being created in the working directory of the storage manager. The temporary file name consists of the prefix, ordinal number and the suffix (e.g., oss12345.tmp, where "oss" is the prefix, ".tmp" is the suffix and the "12345" is the ordinal number, used to make the name unique).
Since:
ASN.1/Java 1.4-beta A
  • Constructor Details

    • OSSStorageManager

      public OSSStorageManager()
  • Method Details

    • getWorkingDirectory

      public static String getWorkingDirectory()
      Return the name of the directory, used by the StorageManager to create the files.
      Returns:
      current setting of the working directory.
    • setWorkingDirectory

      public static void setWorkingDirectory(String workingDirectory, boolean create) throws IOException
      Set the name of the directory to create the files. If the workingDirectory argument is null then the system dependant default temporary-file directory will be used as a working directory for the storage manager. The default temporary-file directory is specified by the system property "java.io.tmpdir".
      Parameters:
      workingDirectory - the name of the directory or null if the default temporary-file directory is to be used.
      create - instructs the storage manager to create the directory if it does not exist (including intermediate directories).
      Throws:
      IOException - if the create is false and the directory does not exist or the if creation of the directory has failed.
    • getPrefix

      public static String getPrefix()
      Get prefix to be used in generating the file's name.
      Returns:
      file name prefix.
    • setPrefix

      public static void setPrefix(String prefix)
      Set prefix to use in generating the file's name.
      Parameters:
      prefix - file name prefix.
    • getSuffix

      public static String getSuffix()
      Get suffix to be used in generating the file's name.
      Returns:
      file name suffix (file extension).
    • setSuffix

      public static void setSuffix(String suffix)
      Set suffix to use in generating the file's name. The suffix is appended to the generated name "as is" (no dot '.' is inserted before the suffix when the name is generated).
      Parameters:
      suffix - file name suffix.
    • getDeleteFilesOnExit

      public static boolean getDeleteFilesOnExit()
      Get current setting of the boolean flag, that requests automatic deletion of temporary files created by the allocate(). The deletion is attempted when the virtual machine terminates.
      Returns:
      true if temporary files were set to be deleted.
    • setDeleteFilesOnExit

      public static void setDeleteFilesOnExit(boolean doDelete)
      Set the boolean flag, that requests automatic deletion of temporary files, created by the allocate(). When the doDelete is true, all temporary files that were created by the storage manager after the invocation of the setDeleteFilesOnExit() will be deleted when the virtual machine terminates.
      Parameters:
      doDelete - true if temporary files should be automatically deleted.
    • generateName

      public static File generateName() throws IOException
      Create a temporary file. The name of the file has the format: wd/PNS, where 'wd' is the working directory, 'P' - prefix, 'N' - ordinal number and 'S' - suffix.
      Returns:
      File object for the name generated.
      Throws:
      IOException - if the creation of the temporary file has failed.
    • allocate

      public Storage allocate(int kind) throws StorageException
      Allocate a storage of a given kind.
      Specified by:
      allocate in interface StorageManager
      Parameters:
      kind - type of the storage to allocate.
      Returns:
      allocated storage object.
      Throws:
      StorageException - if the caller requested the storage of an unknown kind.
    • close

      public void close()
      Terminate the storage manager and release any external resources, that are in use.
      Specified by:
      close in interface StorageManager
    • getInstance

      public static StorageManager getInstance()
      Return an instance of OSSStorageManager.
      Returns:
      shared instance.