public abstract class CachingBinaryManager extends AbstractBinaryManager
BinaryManager that uses a cache for its files because fetching them is expensive.
 
 Initialization of the BinaryManager must call initializeCache(java.io.File, long, long, long, org.nuxeo.ecm.core.blob.binary.FileStorage) from the initialize(java.lang.String, java.util.Map<java.lang.String, java.lang.String>) method.
| Modifier and Type | Field and Description | 
|---|---|
protected File | 
cachedir  | 
FileCache | 
fileCache  | 
protected FileStorage | 
fileStorage  | 
blobProviderId, DEFAULT_DEPTH, DEFAULT_DIGEST, descriptor, DIGESTS_BY_LENGTH, garbageCollector, MAX_BUF_SIZE, MD5_DIGEST, MD5_DIGEST_LENGTH, MIN_BUF_SIZE, SHA1_DIGEST, SHA1_DIGEST_LENGTH, SHA256_DIGEST, SHA256_DIGEST_LENGTHPROP_KEY, PROP_PATH| Constructor and Description | 
|---|
CachingBinaryManager()  | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
close()
Closes the binary manager and releases all resources and temporary objects held by it. 
 | 
protected Binary | 
getBinary(InputStream in)
Creates a binary value from the given input stream. 
 | 
Binary | 
getBinary(String digest)
Returns a  
Binary corresponding to the given digest. | 
File | 
getFile(String digest)
Gets a file from cache or storage. 
 | 
void | 
initialize(String blobProviderId,
          Map<String,String> properties)
Initializes the binary manager. 
 | 
protected void | 
initializeCache(File dir,
               long maxSize,
               long maxCount,
               long minAge,
               FileStorage fileStorage)
Initialize the cache. 
 | 
void | 
initializeCache(String maxSizeStr,
               FileStorage fileStorage)
Initialize the cache. 
 | 
void | 
initializeCache(String maxSizeStr,
               String maxCountStr,
               String minAgeStr,
               FileStorage fileStorage)
Initializes the cache. 
 | 
getBinary, getDefaultDigestAlgorithm, getDescriptor, getDigestAlgorithm, getGarbageCollector, removeBinaries, storeAndDigest, toHexStringprotected FileStorage fileStorage
public CachingBinaryManager()
public void initialize(String blobProviderId, Map<String,String> properties) throws IOException
BinaryManagerinitialize in interface BinaryManagerinitialize in class AbstractBinaryManagerblobProviderId - the blob provider id for this binary managerproperties - initialization propertiesIOExceptionprotected void initializeCache(File dir, long maxSize, long maxCount, long minAge, FileStorage fileStorage)
dir - the directory to use to store cached filesmaxSize - the maximum size of the cache (in bytes)maxCount - the maximum number of files in the cacheminAge - the minimum age of a file in the cache to be eligible for removal (in seconds)fileStorage - the file storage mechanism to use to store and fetch filespublic void initializeCache(String maxSizeStr, FileStorage fileStorage) throws IOException
maxSizeStr - the maximum size of the cache (as a String)fileStorage - the file storage mechanism to use to store and fetch filesIOExceptioninitializeCache(String, String, String, FileStorage)public void initializeCache(String maxSizeStr, String maxCountStr, String minAgeStr, FileStorage fileStorage) throws IOException
maxSizeStr - the maximum size of the cache (as a String)maxCountStr - the maximum number of files in the cacheminAgeStr - the minimum age of a file in the cache to be eligible for removal (in seconds)fileStorage - the file storage mechanism to use to store and fetch filesIOExceptionSizeUtils.parseSizeInBytes(String)public void close()
BinaryManagerprotected Binary getBinary(InputStream in) throws IOException
AbstractBinaryManagergetBinary in class AbstractBinaryManagerIOExceptionpublic Binary getBinary(String digest)
BinaryManagerBinary corresponding to the given digest.
 
 A null is returned if the digest could not be found.
getBinary in interface BinaryManagergetBinary in class AbstractBinaryManagerdigest - the digest, or nullpublic File getFile(String digest) throws IOException
 Used by LazyBinary.
IOExceptionCopyright © 2019 Nuxeo. All rights reserved.