Package org.apache.james.mime4j.storage
Class ThresholdStorageProvider
- java.lang.Object
-
- org.apache.james.mime4j.storage.AbstractStorageProvider
-
- org.apache.james.mime4j.storage.ThresholdStorageProvider
-
- All Implemented Interfaces:
StorageProvider
public class ThresholdStorageProvider extends AbstractStorageProvider
AStorageProvider
that keeps small amounts of data in memory and writes the remainder to anotherStorageProvider
(the back-end) if a certain threshold size gets exceeded.Example usage:
StorageProvider tempStore = new TempFileStorageProvider(); StorageProvider provider = new ThresholdStorageProvider(tempStore, 4096); DefaultStorageProvider.setInstance(provider);
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ThresholdStorageProvider.ThresholdStorage
private class
ThresholdStorageProvider.ThresholdStorageOutputStream
-
Field Summary
Fields Modifier and Type Field Description private StorageProvider
backend
private int
thresholdSize
-
Constructor Summary
Constructors Constructor Description ThresholdStorageProvider(StorageProvider backend)
Creates a newThresholdStorageProvider
for the given back-end using a threshold size of 2048 bytes.ThresholdStorageProvider(StorageProvider backend, int thresholdSize)
Creates a newThresholdStorageProvider
for the given back-end and threshold size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StorageOutputStream
createStorageOutputStream()
Creates aStorageOutputStream
where data to be stored can be written to.-
Methods inherited from class org.apache.james.mime4j.storage.AbstractStorageProvider
store
-
-
-
-
Field Detail
-
backend
private final StorageProvider backend
-
thresholdSize
private final int thresholdSize
-
-
Constructor Detail
-
ThresholdStorageProvider
public ThresholdStorageProvider(StorageProvider backend)
Creates a newThresholdStorageProvider
for the given back-end using a threshold size of 2048 bytes.
-
ThresholdStorageProvider
public ThresholdStorageProvider(StorageProvider backend, int thresholdSize)
Creates a newThresholdStorageProvider
for the given back-end and threshold size.- Parameters:
backend
- used to store the remainder of the data if the threshold size gets exceeded.thresholdSize
- determines how much bytes are kept in memory before that back-end storage provider is used to store the remainder of the data.
-
-
Method Detail
-
createStorageOutputStream
public StorageOutputStream createStorageOutputStream()
Description copied from interface:StorageProvider
Creates aStorageOutputStream
where data to be stored can be written to. Subsequently the user can calltoStorage()
on that object to get aStorage
instance that holds the data that has been written.- Returns:
- a
StorageOutputStream
where data can be written to.
-
-