public class SoftRefFilesCache extends AbstractFilesCache
SoftReference
Modifier and Type | Class and Description |
---|---|
private class |
SoftRefFilesCache.SoftRefReleaseThread
This thread will listen on the ReferenceQueue and remove the entry in the
filescache as soon as the vm removes the reference
|
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.ConcurrentMap<FileSystem,java.util.Map<FileName,java.lang.ref.Reference<FileObject>>> |
fileSystemCache |
private java.util.concurrent.locks.Lock |
lock |
private static org.apache.commons.logging.Log |
log |
private java.lang.ref.ReferenceQueue<FileObject> |
refQueue |
private java.util.Map<java.lang.ref.Reference<FileObject>,FileSystemAndNameKey> |
refReverseMap |
private SoftRefFilesCache.SoftRefReleaseThread |
softRefReleaseThread |
private static int |
TIMEOUT |
Constructor and Description |
---|
SoftRefFilesCache() |
Modifier and Type | Method and Description |
---|---|
void |
clear(FileSystem fileSystem)
Purges the entries corresponding to the FileSystem.
|
void |
close()
Closes the provider.
|
private void |
close(FileSystem fileSystem)
Called while the lock is held
|
protected java.lang.ref.Reference<FileObject> |
createReference(FileObject file,
java.lang.ref.ReferenceQueue<FileObject> refqueue) |
private void |
endThread() |
FileObject |
getFile(FileSystem fileSystem,
FileName fileName)
Retrieves a FileObject from the cache by name.
|
protected java.util.Map<FileName,java.lang.ref.Reference<FileObject>> |
getOrCreateFilesystemCache(FileSystem fileSystem) |
private java.lang.String |
getSafeName(FileName fileName) |
private java.lang.String |
getSafeName(FileObject fileObject) |
void |
putFile(FileObject fileObject)
Adds a FileObject to the cache.
|
boolean |
putFileIfAbsent(FileObject fileObject)
Adds a FileObject to the cache if it isn't already present.
|
private boolean |
removeFile(FileSystemAndNameKey key) |
void |
removeFile(FileSystem fileSystem,
FileName fileName)
Removes a file from cache.
|
private void |
startThread() |
touchFile
getContext, getLogger, init, setContext, setLogger
private static final int TIMEOUT
private static final org.apache.commons.logging.Log log
private final java.util.concurrent.ConcurrentMap<FileSystem,java.util.Map<FileName,java.lang.ref.Reference<FileObject>>> fileSystemCache
private final java.util.Map<java.lang.ref.Reference<FileObject>,FileSystemAndNameKey> refReverseMap
private final java.lang.ref.ReferenceQueue<FileObject> refQueue
private volatile SoftRefFilesCache.SoftRefReleaseThread softRefReleaseThread
private final java.util.concurrent.locks.Lock lock
private void startThread()
private void endThread()
public void putFile(FileObject fileObject)
FilesCache
fileObject
- the fileprivate java.lang.String getSafeName(FileName fileName)
private java.lang.String getSafeName(FileObject fileObject)
public boolean putFileIfAbsent(FileObject fileObject)
FilesCache
fileObject
- the fileprotected java.lang.ref.Reference<FileObject> createReference(FileObject file, java.lang.ref.ReferenceQueue<FileObject> refqueue)
public FileObject getFile(FileSystem fileSystem, FileName fileName)
FilesCache
fileSystem
- The FileSystem.fileName
- the namepublic void clear(FileSystem fileSystem)
FilesCache
fileSystem
- The FileSystem.private void close(FileSystem fileSystem)
fileSystem
- The file system to close.public void close()
AbstractVfsComponent
close
in interface FilesCache
close
in interface VfsComponent
close
in class AbstractVfsComponent
public void removeFile(FileSystem fileSystem, FileName fileName)
FilesCache
fileSystem
- filesystemfileName
- filenameprivate boolean removeFile(FileSystemAndNameKey key)
protected java.util.Map<FileName,java.lang.ref.Reference<FileObject>> getOrCreateFilesystemCache(FileSystem fileSystem)