public abstract class AbstractFileSystem extends AbstractVfsComponent implements FileSystem
FileSystem
implementation.Modifier and Type | Field and Description |
---|---|
private FileSystemKey |
cacheKey |
private java.util.Collection<Capability> |
caps |
private FileSystemOptions |
fileSystemOptions
FileSystemOptions used for configuration
|
private java.util.Map<FileName,java.util.ArrayList<FileListener>> |
listenerMap
Map from FileName to an ArrayList of listeners for that file.
|
private static org.apache.commons.logging.Log |
LOG |
private java.util.concurrent.atomic.AtomicInteger |
openStreams
open streams counter for this filesystem
|
private FileObject |
parentLayer |
private FileName |
rootName
The "root" of the file system.
|
private java.lang.String |
rootURI
The root URI of the file system.
|
private java.util.concurrent.atomic.AtomicLong |
useCount
How many fileObjects are handed out
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractFileSystem(FileName rootName,
FileObject parentLayer,
FileSystemOptions fileSystemOptions) |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
addCapabilities(java.util.Collection<Capability> caps)
Adds the capabilities of this file system.
|
void |
addJunction(java.lang.String junctionPoint,
FileObject targetFile)
Adds a junction to this file system.
|
void |
addListener(FileObject file,
FileListener listener)
Adds a listener on a file in this file system.
|
void |
close()
Closes this component.
|
void |
closeCommunicationLink()
Close the underlying link used to access the files.
|
protected abstract FileObject |
createFile(AbstractFileName name)
Creates a file object.
|
protected FileObject |
decorateFileObject(FileObject file) |
protected void |
doCloseCommunicationLink()
Close the underlying link used to access the files
|
protected java.io.File |
doReplicateFile(FileObject file,
FileSelector selector)
Creates a temporary local copy of a file and its descendants.
|
(package private) void |
fileObjectDestroyed(FileObject fileObject) |
(package private) void |
fileObjectHanded(FileObject fileObject) |
private void |
fireEvent(AbstractFileChangeEvent event)
Fires an event.
|
void |
fireFileChanged(FileObject file)
Fires a file changed event.
|
void |
fireFileCreated(FileObject file)
Fires a file create event.
|
void |
fireFileDeleted(FileObject file)
Fires a file delete event.
|
(package private) void |
freeResources() |
java.lang.Object |
getAttribute(java.lang.String attrName)
Retrieves the attribute with the specified name.
|
private FilesCache |
getCache() |
(package private) FileSystemKey |
getCacheKey() |
protected FileObject |
getFileFromCache(FileName name)
Returns a cached file.
|
FileSystemManager |
getFileSystemManager()
Return the FileSystemManager used to instantiate this filesystem.
|
FileSystemOptions |
getFileSystemOptions()
Return the FileSystemOptions used to instantiate this filesystem.
|
double |
getLastModTimeAccuracy()
Returns the accuracy of the last modification time.
|
FileObject |
getParentLayer()
Returns the parent layer if this is a layered file system.
|
FileObject |
getRoot()
Returns the root file of this file system.
|
FileName |
getRootName()
Returns the name of the root of this file system.
|
java.lang.String |
getRootURI()
Returns the root URI specified for this file System.
|
boolean |
hasCapability(Capability capability)
Determines if this file system has a particular capability.
|
void |
init()
Initializes this component.
|
boolean |
isOpen()
check if this filesystem has open streams.
|
boolean |
isReleaseable()
Returns true if no file is using this filesystem.
|
protected void |
notifyAllStreamsClosed()
will be called after all file-objects closed their streams.
|
protected void |
putFileToCache(FileObject file)
Adds a file object to the cache.
|
protected void |
removeFileFromCache(FileName name)
Remove a cached file.
|
void |
removeJunction(java.lang.String junctionPoint)
Removes a junction from this file system.
|
void |
removeListener(FileObject file,
FileListener listener)
Removes a listener from a file in this file system.
|
java.io.File |
replicateFile(FileObject file,
FileSelector selector)
Creates a temporary local copy of a file and its descendants.
|
FileObject |
resolveFile(FileName name)
Finds a file in this file system.
|
private FileObject |
resolveFile(FileName name,
boolean useCache) |
FileObject |
resolveFile(java.lang.String nameStr)
Finds a file in this file system.
|
void |
setAttribute(java.lang.String attrName,
java.lang.Object value)
Sets the attribute with the specified name.
|
(package private) void |
setCacheKey(FileSystemKey cacheKey) |
(package private) void |
streamClosed() |
(package private) void |
streamOpened() |
getContext, getLogger, setContext, setLogger
private static final org.apache.commons.logging.Log LOG
private final FileName rootName
private final java.lang.String rootURI
private final java.util.Collection<Capability> caps
private FileObject parentLayer
private final java.util.Map<FileName,java.util.ArrayList<FileListener>> listenerMap
private final FileSystemOptions fileSystemOptions
private final java.util.concurrent.atomic.AtomicLong useCount
private FileSystemKey cacheKey
private final java.util.concurrent.atomic.AtomicInteger openStreams
protected AbstractFileSystem(FileName rootName, FileObject parentLayer, FileSystemOptions fileSystemOptions)
public void init() throws FileSystemException
init
in interface VfsComponent
init
in class AbstractVfsComponent
FileSystemException
- if an error occurs.public void close()
close
in interface VfsComponent
close
in class AbstractVfsComponent
public void closeCommunicationLink()
protected void doCloseCommunicationLink()
protected abstract FileObject createFile(AbstractFileName name) throws java.lang.Exception
This method is called only if the requested file is not cached.
name
- name referencing the new file.java.lang.Exception
- might throw an Exception, which is then wrapped in FileSystemException.protected abstract void addCapabilities(java.util.Collection<Capability> caps)
caps
- collections of Capabilities, can be immutable.public FileName getRootName()
getRootName
in interface FileSystem
public java.lang.String getRootURI()
getRootURI
in interface FileSystem
protected void putFileToCache(FileObject file)
file
- the file to add.private FilesCache getCache()
protected FileObject getFileFromCache(FileName name)
name
- name to search for.protected void removeFileFromCache(FileName name)
name
- The file name to remove.public boolean hasCapability(Capability capability)
hasCapability
in interface FileSystem
capability
- the Capability to check for.public java.lang.Object getAttribute(java.lang.String attrName) throws FileSystemException
getAttribute
in interface FileSystem
attrName
- The name of the attribute.FileSystemException
- if an error occurs.FileContent.getAttribute(java.lang.String)
public void setAttribute(java.lang.String attrName, java.lang.Object value) throws FileSystemException
setAttribute
in interface FileSystem
attrName
- the attribute name.value
- The object to associate with the attribute.FileSystemException
- if an error occurs.FileContent.setAttribute(java.lang.String, java.lang.Object)
public FileObject getParentLayer() throws FileSystemException
getParentLayer
in interface FileSystem
FileSystemException
- if an error occurs.public FileObject getRoot() throws FileSystemException
getRoot
in interface FileSystem
FileSystemException
- if an error occurs.public FileObject resolveFile(java.lang.String nameStr) throws FileSystemException
resolveFile
in interface FileSystem
nameStr
- The name of the file to resolve.FileSystemException
- if an error occurs.public FileObject resolveFile(FileName name) throws FileSystemException
resolveFile
in interface FileSystem
name
- The name of the file to locate.FileSystemException
- if an error occurs.private FileObject resolveFile(FileName name, boolean useCache) throws FileSystemException
FileSystemException
protected FileObject decorateFileObject(FileObject file) throws FileSystemException
FileSystemException
public java.io.File replicateFile(FileObject file, FileSelector selector) throws FileSystemException
replicateFile
in interface FileSystem
file
- The FileObject to replicate.selector
- The FileSelector.FileSystemException
- if an error occurs.public FileSystemOptions getFileSystemOptions()
getFileSystemOptions
in interface FileSystem
public FileSystemManager getFileSystemManager()
getFileSystemManager
in interface FileSystem
public double getLastModTimeAccuracy()
getLastModTimeAccuracy
in interface FileSystem
protected java.io.File doReplicateFile(FileObject file, FileSelector selector) throws java.lang.Exception
file
- the start of the tree.selector
- selection what to do with childs.java.lang.Exception
- any Exception is wrapped as FileSystemException.public void addJunction(java.lang.String junctionPoint, FileObject targetFile) throws FileSystemException
addJunction
in interface FileSystem
junctionPoint
- The junction point.targetFile
- The target to add.FileSystemException
- if an error occurs.public void removeJunction(java.lang.String junctionPoint) throws FileSystemException
removeJunction
in interface FileSystem
junctionPoint
- The junction point.FileSystemException
- if an error occurspublic void addListener(FileObject file, FileListener listener)
addListener
in interface FileSystem
file
- The FileObject to be monitored.listener
- The FileListenerpublic void removeListener(FileObject file, FileListener listener)
removeListener
in interface FileSystem
file
- The FileObject to be monitored.listener
- The FileListenerpublic void fireFileCreated(FileObject file)
file
- The FileObject that was created.public void fireFileDeleted(FileObject file)
file
- The FileObject that was deleted.public void fireFileChanged(FileObject file)
This will only happen if you monitor the file using FileMonitor
.
file
- The FileObject that changed.public boolean isReleaseable()
void freeResources()
private void fireEvent(AbstractFileChangeEvent event)
void fileObjectHanded(FileObject fileObject)
void fileObjectDestroyed(FileObject fileObject)
void setCacheKey(FileSystemKey cacheKey)
FileSystemKey getCacheKey()
void streamOpened()
void streamClosed()
protected void notifyAllStreamsClosed()
public boolean isOpen()