Package org.ghost4j.util
Class DiskStore
java.lang.Object
org.ghost4j.util.DiskStore
Singleton class used to store and retrieve files to / from a temporary disk
storage.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd a file to the store.Generates a unique diskstore key.Retrieve a File from a store key.static DiskStore
Access to the shared instance.void
removeFile
(String key) Remove a file from the store.
-
Field Details
-
ROOT_PATH
-
instance
Shared instance. -
map
Map used to store references to temprorary files.
-
-
Constructor Details
-
DiskStore
private DiskStore()Private constructor.
-
-
Method Details
-
getInstance
Access to the shared instance.- Returns:
- The shared DiskStore instance.
-
generateUniqueKey
Generates a unique diskstore key. Use the JVM PID and UUID.- Returns:
- A unique key as string
-
getFile
Retrieve a File from a store key. If key is unknown, null is returned.- Parameters:
key
- Unique file resource identifier.- Returns:
- File or null (if not found).
-
removeFile
Remove a file from the store. This also deleted the temporary file from the file system.- Parameters:
key
- Unique file resource identifier.- Throws:
IOException
- In case the file cannot be deleted.
-
addFile
Add a file to the store.- Parameters:
key
- File unique identifier.- Returns:
- The generated (empty) file.
-