Package org.apache.commons.vfs2.cache
Class SoftRefFilesCache
- java.lang.Object
-
- org.apache.commons.vfs2.provider.AbstractVfsComponent
-
- org.apache.commons.vfs2.cache.AbstractFilesCache
-
- org.apache.commons.vfs2.cache.SoftRefFilesCache
-
- All Implemented Interfaces:
FilesCache,VfsComponent
- Direct Known Subclasses:
WeakRefFilesCache
public class SoftRefFilesCache extends AbstractFilesCache
This implementation caches every file as long as it is strongly reachable by the java vm. As soon as the vm needs memory - every softly reachable file will be discarded.- See Also:
SoftReference
-
-
Constructor Summary
Constructors Constructor Description SoftRefFilesCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear(FileSystem fileSystem)Purges the entries corresponding to the FileSystem.voidclose()Closes the provider.protected java.lang.ref.Reference<FileObject>createReference(FileObject file, java.lang.ref.ReferenceQueue<FileObject> refqueue)FileObjectgetFile(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)voidputFile(FileObject fileObject)Adds a FileObject to the cache.booleanputFileIfAbsent(FileObject fileObject)Adds a FileObject to the cache if it isn't already present.voidremoveFile(FileSystem fileSystem, FileName fileName)Removes a file from cache.-
Methods inherited from class org.apache.commons.vfs2.cache.AbstractFilesCache
touchFile
-
Methods inherited from class org.apache.commons.vfs2.provider.AbstractVfsComponent
getContext, getLogger, init, setContext, setLogger
-
-
-
-
Constructor Detail
-
SoftRefFilesCache
public SoftRefFilesCache()
-
-
Method Detail
-
putFile
public void putFile(FileObject fileObject)
Description copied from interface:FilesCacheAdds a FileObject to the cache.- Parameters:
fileObject- the file
-
putFileIfAbsent
public boolean putFileIfAbsent(FileObject fileObject)
Description copied from interface:FilesCacheAdds a FileObject to the cache if it isn't already present.- Parameters:
fileObject- the file- Returns:
- true if the file was stored, false otherwise.
-
createReference
protected java.lang.ref.Reference<FileObject> createReference(FileObject file, java.lang.ref.ReferenceQueue<FileObject> refqueue)
-
getFile
public FileObject getFile(FileSystem fileSystem, FileName fileName)
Description copied from interface:FilesCacheRetrieves a FileObject from the cache by name.- Parameters:
fileSystem- The FileSystem.fileName- the name- Returns:
- the file object or null if file is not cached
-
clear
public void clear(FileSystem fileSystem)
Description copied from interface:FilesCachePurges the entries corresponding to the FileSystem.- Parameters:
fileSystem- The FileSystem.
-
close
public void close()
Description copied from class:AbstractVfsComponentCloses the provider. This implementation does nothing.- Specified by:
closein interfaceFilesCache- Specified by:
closein interfaceVfsComponent- Overrides:
closein classAbstractVfsComponent
-
removeFile
public void removeFile(FileSystem fileSystem, FileName fileName)
Description copied from interface:FilesCacheRemoves a file from cache.- Parameters:
fileSystem- filesystemfileName- filename
-
getOrCreateFilesystemCache
protected java.util.Map<FileName,java.lang.ref.Reference<FileObject>> getOrCreateFilesystemCache(FileSystem fileSystem)
-
-