public class DeferredFileStreamStorageFactory extends Object implements StreamStorageFactory
FileStreamStorages.
The factory can be configured to:
FileStreamStorages are storedFileStreamStoragesFileStreamStorages that will delete the underlying file after closing its InputStreamFileStreamStorages that will delete the underlying file after disposing the FileStreamStorage itselfFileStreamStorages with a maximum capacity| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_MAX_CAPACITY
Default maximum capacity to set to the new
StreamStorages. |
static int |
DEFAULT_MAX_THRESHOLD
Default max threshold.
|
static String |
DEFAULT_ROOT_FOLDER
Default location where the data files are stored.
|
| Constructor and Description |
|---|
DeferredFileStreamStorageFactory()
Constructor that uses a default threshold of 10kb and a default folder ${java.io.tmpdir}/nio-stream-storage.
|
DeferredFileStreamStorageFactory(int maxSizeThreshold)
Constructor that uses a default folder ${java.io.tmpdir}/nio-stream-storage.
|
DeferredFileStreamStorageFactory(String tempFolderPath)
Constructor that uses the default threshold of 10kb.
|
DeferredFileStreamStorageFactory(String rootFolderPath,
int maxSizeThreshold)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
StreamStorage |
create()
Creates a new
FileStreamStorage. |
protected String |
getFileName()
Generates an unique file name for the data file.
|
void |
setDeleteFilesOnClose(boolean deleteFilesOnClose) |
void |
setDeleteFilesOnDispose(boolean deleteFilesOnDispose) |
void |
setMaxCapacity(long maxCapacity) |
public static final int DEFAULT_MAX_THRESHOLD
public static final int DEFAULT_MAX_CAPACITY
Default maximum capacity to set to the new StreamStorages. The default is infinite and it can be changed via the setMaxCapacity(long) method.
public static final String DEFAULT_ROOT_FOLDER
Default location where the data files are stored.
public DeferredFileStreamStorageFactory(String rootFolderPath, int maxSizeThreshold)
Constructor.
rootFolderPath - The path to the folder where data files will be stored if the max threshold is reached.maxSizeThreshold - The threshold in bytes. When the data in memory exceeds this threshold it will be written to a temporary file.public DeferredFileStreamStorageFactory(String tempFolderPath)
Constructor that uses the default threshold of 10kb.
tempFolderPath - The path to the folder were temporary data will be stored if the max threshold is reached.public DeferredFileStreamStorageFactory(int maxSizeThreshold)
Constructor that uses a default folder ${java.io.tmpdir}/nio-stream-storage.
maxSizeThreshold - The threshold in bytes. When the data in memory exceeds this threshold it will be written to a temporary file.public DeferredFileStreamStorageFactory()
Constructor that uses a default threshold of 10kb and a default folder ${java.io.tmpdir}/nio-stream-storage.
public void setDeleteFilesOnClose(boolean deleteFilesOnClose)
public void setDeleteFilesOnDispose(boolean deleteFilesOnDispose)
public void setMaxCapacity(long maxCapacity)
public StreamStorage create()
FileStreamStorage.create in interface StreamStorageFactoryStreamStorage to store bytes temporarily in-memory or on disk if over the configured threshold.protected String getFileName()
Generates an unique file name for the data file.
Copyright © 2017. All rights reserved.