Class DefaultFileSystemManager
java.lang.Object
org.apache.commons.vfs.impl.DefaultFileSystemManager
- All Implemented Interfaces:
FileSystemManager
- Direct Known Subclasses:
StandardFileSystemManager
A default file system manager implementation.
- Version:
- $Revision: 484648 $ $Date: 2006-03-30 21:16:24 +0200 (Do, 30 Mrz 2006) $
- Author:
- Adam Murdoch
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid_closeFileSystem(FileSystem filesystem) Closes the given filesystem.
If you use VFS as singleton it is VERY dangerous to call this methodvoidaddExtensionMap(String extension, String scheme) Adds an filename extension mapping.voidaddMimeTypeMap(String mimeType, String scheme) Adds a mime type mapping.voidaddOperationProvider(String[] schemes, FileOperationProvider operationProvider) voidaddOperationProvider(String scheme, FileOperationProvider operationProvider) Adds the specified FileOperationProvider for the specified scheme.voidaddProvider(String[] urlSchemes, FileProvider provider) Registers a file system provider.voidaddProvider(String urlScheme, FileProvider provider) Registers a file system provider.booleanDetermines if a layered file system can be created for a given file.voidclose()Closes all files created by this manager, and cleans up any temporary files.voidcloseFileSystem(FileSystem filesystem) Closes the given filesystem.
If you use VFS as singleton it is VERY dangerous to call this methodcreateFileSystem(String scheme, FileObject file) Creates a layered file system.createFileSystem(FileObject file) Creates a layered file system.createVirtualFileSystem(String rootUri) Creates an empty virtual file system.createVirtualFileSystem(FileObject rootFile) Creates a virtual file system.voidFree all resources used by unused filesystems created by this manager.Returns the base file used to resolve relative URI.Get the cache strategy usedget the fileContentInfoFactory used to determine the infos of a file content.Get the file object decorator usedThe constructor associated to the fileObjectDecorator.Returns the filesCache implementation used to cache filesgetFileSystemConfigBuilder(String scheme) Get the configuration builder for the given schemeprotected org.apache.commons.logging.LogReturns the logger used by this manager.getOperationProviders(String scheme) getProviderCapabilities(String scheme) Get the capabilities for a given scheme.Returns the file replicator.String[]Get the schemes currently available.Returns the temporary file store.Get the URLStreamHandlerFactory.booleanhasProvider(String scheme) Returns true if this manager has a provider for a particular scheme.voidinit()Initialises this manager.resolveFile(File baseFile, String uri) Locates a file by URI.resolveFile(String uri) Locates a file by URI.resolveFile(String uri, FileSystemOptions fileSystemOptions) Locate a file by URI, use the FileSystemOptions for file-system creationresolveFile(FileObject baseFile, String uri) Resolves a URI, relative to a base file.resolveFile(FileObject baseFile, String uri, FileSystemOptions fileSystemOptions) Resolves a URI, realtive to a base file with specified FileSystem configurationresolveName(FileName root, String path) Resolves a name, relative to the file.resolveName(FileName base, String name, NameScope scope) Resolves a name, relative to the root.resolveURI(String uri) resolve the uri to a filenamevoidsetBaseFile(File baseFile) Sets the base file to use when resolving relative URI.voidsetBaseFile(FileObject baseFile) Sets the base file to use when resolving relative URI.voidsetCacheStrategy(CacheStrategy fileCacheStrategy) Set the cache strategy to use when dealing with file object data.voidsetDefaultProvider(FileProvider provider) Sets the default provider.voidsetFileContentInfoFactory(FileContentInfoFactory fileContentInfoFactory) set the fileContentInfoFactory used to determine the infos of a file content.voidsetFileObjectDecorator(Class fileObjectDecorator) set a fileObject decorator to be used for ALL returned file objectsvoidsetFilesCache(FilesCache filesCache) Sets the filesCache implementation used to cache filesvoidsetLogger(org.apache.commons.logging.Log log) Sets the logger to use.voidsetReplicator(FileReplicator replicator) Sets the file replicator to use.voidsetTemporaryFileStore(TemporaryFileStore tempFileStore) Sets the temporary file store to use.toFileObject(File file) Converts a local file into aFileObject.
-
Constructor Details
-
DefaultFileSystemManager
public DefaultFileSystemManager()
-
-
Method Details
-
getLogger
protected org.apache.commons.logging.Log getLogger()Returns the logger used by this manager. -
addProvider
Registers a file system provider. The manager takes care of all lifecycle management. A provider may be registered multiple times.- Parameters:
urlScheme- The scheme the provider will handle.provider- The provider.- Throws:
FileSystemException
-
addProvider
Registers a file system provider. The manager takes care of all lifecycle management. A provider may be registered multiple times.- Parameters:
urlSchemes- The schemes the provider will handle.provider- The provider.- Throws:
FileSystemException
-
hasProvider
Returns true if this manager has a provider for a particular scheme. -
addExtensionMap
-
addMimeTypeMap
-
setDefaultProvider
Sets the default provider. This is the provider that will handle URI with unknown schemes. The manager takes care of all lifecycle management.- Throws:
FileSystemException
-
getFilesCache
Returns the filesCache implementation used to cache files- Specified by:
getFilesCachein interfaceFileSystemManager
-
setFilesCache
Sets the filesCache implementation used to cache files- Throws:
FileSystemException
-
setCacheStrategy
Set the cache strategy to use when dealing with file object data. You can set it only once before the FileSystemManager is initialized.
The default is
CacheStrategy.ON_RESOLVE- Throws:
FileSystemException- if this is not possible. e.g. it is already set.
-
getCacheStrategy
Get the cache strategy used- Specified by:
getCacheStrategyin interfaceFileSystemManager
-
getFileObjectDecorator
Get the file object decorator used- Specified by:
getFileObjectDecoratorin interfaceFileSystemManager
-
getFileObjectDecoratorConst
The constructor associated to the fileObjectDecorator. We cache it here for performance reasons.- Specified by:
getFileObjectDecoratorConstin interfaceFileSystemManager
-
setFileObjectDecorator
set a fileObject decorator to be used for ALL returned file objects- Parameters:
fileObjectDecorator- must be inherted fromDecoratedFileObjecta has to provide a constructor with a singleFileObjectas argument- Throws:
FileSystemException
-
getFileContentInfoFactory
get the fileContentInfoFactory used to determine the infos of a file content.- Specified by:
getFileContentInfoFactoryin interfaceFileSystemManager
-
setFileContentInfoFactory
public void setFileContentInfoFactory(FileContentInfoFactory fileContentInfoFactory) throws FileSystemException set the fileContentInfoFactory used to determine the infos of a file content.- Throws:
FileSystemException
-
setReplicator
Sets the file replicator to use. The manager takes care of all lifecycle management.- Throws:
FileSystemException
-
setTemporaryFileStore
Sets the temporary file store to use. The manager takes care of all lifecycle management.- Throws:
FileSystemException
-
setLogger
public void setLogger(org.apache.commons.logging.Log log) Sets the logger to use.- Specified by:
setLoggerin interfaceFileSystemManager
-
getReplicator
Returns the file replicator.- Returns:
- The file replicator. Never returns null.
- Throws:
FileSystemException
-
getTemporaryFileStore
Returns the temporary file store.- Returns:
- The file store. Never returns null.
- Throws:
FileSystemException
-
init
-
close
public void close()Closes all files created by this manager, and cleans up any temporary files. Also closes all providers and the replicator. -
freeUnusedResources
public void freeUnusedResources()Free all resources used by unused filesystems created by this manager. -
setBaseFile
Sets the base file to use when resolving relative URI.- Throws:
FileSystemException
-
setBaseFile
Sets the base file to use when resolving relative URI.- Throws:
FileSystemException
-
getBaseFile
Returns the base file used to resolve relative URI.- Specified by:
getBaseFilein interfaceFileSystemManager- Throws:
FileSystemException
-
resolveFile
Locates a file by URI.- Specified by:
resolveFilein interfaceFileSystemManager- Parameters:
uri- The name of the file.- Returns:
- The file. Never returns null.
- Throws:
FileSystemException- On error parsing the file name.
-
resolveFile
public FileObject resolveFile(String uri, FileSystemOptions fileSystemOptions) throws FileSystemException Locate a file by URI, use the FileSystemOptions for file-system creation- Specified by:
resolveFilein interfaceFileSystemManager- Parameters:
uri- The name of the file.fileSystemOptions- The FileSystemOptions used for FileSystem creation- Returns:
- The file. Never returns null.
- Throws:
FileSystemException- On error parsing the file name.
-
resolveFile
Locates a file by URI.- Specified by:
resolveFilein interfaceFileSystemManager- Parameters:
baseFile- The base file to use to resolve relative paths. May be null.uri- The name of the file.- Returns:
- The file. Never returns null.
- Throws:
FileSystemException- On error parsing the file name.
-
resolveFile
Resolves a URI, relative to a base file.- Specified by:
resolveFilein interfaceFileSystemManager- Parameters:
baseFile- The base file to use to resolve relative paths. May be null.uri- The name of the file.- Returns:
- The file. Never returns null.
- Throws:
FileSystemException- On error parsing the file name.
-
resolveFile
public FileObject resolveFile(FileObject baseFile, String uri, FileSystemOptions fileSystemOptions) throws FileSystemException Resolves a URI, realtive to a base file with specified FileSystem configuration- Throws:
FileSystemException
-
resolveName
Resolves a name, relative to the file. If the supplied name is an absolute path, then it is resolved relative to the root of the file system that the file belongs to. If a relative name is supplied, then it is resolved relative to this file name.- Specified by:
resolveNamein interfaceFileSystemManager- Parameters:
root- the base filenamepath- The name to resolve.- Returns:
- A
FileNameobject representing the resolved file name. - Throws:
FileSystemException- If the name is invalid.
-
resolveName
Resolves a name, relative to the root.- Specified by:
resolveNamein interfaceFileSystemManager- Parameters:
base- the base filenamename- the namescope- theNameScope- Returns:
- A
FileNameobject representing the resolved file name. - Throws:
FileSystemException
-
resolveURI
resolve the uri to a filename- Specified by:
resolveURIin interfaceFileSystemManager- Throws:
FileSystemException
-
toFileObject
Converts a local file into aFileObject.- Specified by:
toFileObjectin interfaceFileSystemManager- Parameters:
file- The file to convert.- Returns:
- The
FileObjectthat represents the local file. Never returns null. - Throws:
FileSystemException- On error converting the file.
-
createFileSystem
Creates a layered file system.- Specified by:
createFileSystemin interfaceFileSystemManager- Parameters:
scheme- The name of the file system provider to use. This name is the same as the scheme used in URI to identify the provider.file- The file to use to create the file system.- Returns:
- The root file of the new file system.
- Throws:
FileSystemException- On error creating the file system.
-
createFileSystem
Creates a layered file system.- Specified by:
createFileSystemin interfaceFileSystemManager- Parameters:
file- The file to use to create the file system.- Returns:
- The root file of the new file system.
- Throws:
FileSystemException- On error creating the file system.
-
canCreateFileSystem
Determines if a layered file system can be created for a given file.- Specified by:
canCreateFileSystemin interfaceFileSystemManager- Parameters:
file- The file to check for.- Throws:
FileSystemException
-
createVirtualFileSystem
Creates a virtual file system.- Specified by:
createVirtualFileSystemin interfaceFileSystemManager- Parameters:
rootFile- The root file to backs the file system.- Returns:
- The root of the new file system.
- Throws:
FileSystemException
-
createVirtualFileSystem
Creates an empty virtual file system.- Specified by:
createVirtualFileSystemin interfaceFileSystemManager- Parameters:
rootUri- The root URI to use for the new file system. Can be null.- Returns:
- The root file of the new file system.
- Throws:
FileSystemException
-
getURLStreamHandlerFactory
Get the URLStreamHandlerFactory.- Specified by:
getURLStreamHandlerFactoryin interfaceFileSystemManager
-
closeFileSystem
Closes the given filesystem.
If you use VFS as singleton it is VERY dangerous to call this method- Specified by:
closeFileSystemin interfaceFileSystemManager
-
_closeFileSystem
Closes the given filesystem.
If you use VFS as singleton it is VERY dangerous to call this method -
getSchemes
Get the schemes currently available.- Specified by:
getSchemesin interfaceFileSystemManager
-
getProviderCapabilities
Get the capabilities for a given scheme.- Specified by:
getProviderCapabilitiesin interfaceFileSystemManager- Throws:
FileSystemException- if the given scheme is not konwn
-
getFileSystemConfigBuilder
Get the configuration builder for the given scheme- Specified by:
getFileSystemConfigBuilderin interfaceFileSystemManager- Throws:
FileSystemException- if the given scheme is not konwn
-
addOperationProvider
public void addOperationProvider(String scheme, FileOperationProvider operationProvider) throws FileSystemException Adds the specified FileOperationProvider for the specified scheme. Several FileOperationProvider's might be registered for the same scheme. For example, for "file" scheme we can register SvnWsOperationProvider and CvsOperationProvider.- Specified by:
addOperationProviderin interfaceFileSystemManager- Parameters:
scheme-operationProvider-- Throws:
FileSystemException
-
addOperationProvider
public void addOperationProvider(String[] schemes, FileOperationProvider operationProvider) throws FileSystemException - Specified by:
addOperationProviderin interfaceFileSystemManager- Parameters:
schemes-operationProvider-- Throws:
FileSystemException- See Also:
-
getOperationProviders
- Specified by:
getOperationProvidersin interfaceFileSystemManager- Parameters:
scheme- the scheme for wich we want to get the list af registered providers.- Returns:
- the registered FileOperationProviders for the specified scheme. If there were no providers registered for the scheme, it returns null.
- Throws:
FileSystemException
-