Package org.apache.commons.vfs2.impl
Class StandardFileSystemManager
java.lang.Object
org.apache.commons.vfs2.impl.DefaultFileSystemManager
org.apache.commons.vfs2.impl.StandardFileSystemManager
- All Implemented Interfaces:
AutoCloseable
,FileSystemManager
A
FileSystemManager
that configures itself from an XML (Default: providers.xml)
configuration file.
Certain providers are only loaded and available if the dependent library is in your classpath. You have to configure your debugging facility to log "debug" messages to see if a provider was skipped due to "unresolved externals".
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.commons.vfs2.impl.DefaultFileSystemManager
DefaultFileSystemManager.VfsStreamHandlerFactory
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ClassLoader
private static final String
private URL
private static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addExtensionMap
(Element map) Adds an extension map.private void
addMimeTypeMap
(Element map) Adds a mime-type map.private void
addOperationProvider
(Element providerDef) Adds a operationProvider from a operationProvider definition.private void
addProvider
(Element providerDef, boolean isDefault) Adds a provider from a provider definition.private void
configure
(String configUri, InputStream configStream) Configures this manager from an XML configuration file.private void
Configures this manager from an XML configuration file.private void
Configures this manager from an parsed XML configuration fileprotected void
Scans the classpath to find any droped plugin.protected DefaultFileReplicator
private DocumentBuilder
Configure and create a DocumentBuilderprivate Object
createInstance
(String className) Creates a provider.private Enumeration<URL>
enumerateResources
(String name) Enumerates resources from different class loaders.private boolean
Tests if a class is available.private ClassLoader
Returns a class loader or null since some Java implementation is null for the bootstrap class loader.private String[]
getRequiredClasses
(Element providerDef) Extracts the required classes from a provider definition.private String[]
getRequiredSchemes
(Element providerDef) Extracts the required schemes from a provider definition.private String[]
getSchemas
(Element provider) Extracts the schema names from a provider definition.private ClassLoader
getValidClassLoader
(Class<?> clazz) void
init()
Initializes this manager.private Class<?>
Load a class from different class loaders.void
setClassLoader
(ClassLoader classLoader) Sets the ClassLoader to use to load the providers.void
setConfiguration
(String configUri) Sets the configuration file for this manager.void
setConfiguration
(URL configUri) Sets the configuration file for this manager.private ClassLoader
validateClassLoader
(ClassLoader clazzLoader, Class<?> clazz) Methods inherited from class org.apache.commons.vfs2.impl.DefaultFileSystemManager
_closeFileSystem, addExtensionMap, addMimeTypeMap, addOperationProvider, addOperationProvider, addProvider, addProvider, addVirtualFileSystemScheme, canCreateFileSystem, close, closeFileSystem, createFileSystem, createFileSystem, createVirtualFileSystem, createVirtualFileSystem, freeUnusedResources, getBaseFile, getCacheStrategy, getFileContentInfoFactory, getFileObjectDecorator, getFileObjectDecoratorConst, getFilesCache, getFileSystemConfigBuilder, getLogger, getOperationProviders, getProviderCapabilities, getReplicator, getSchemes, getTemporaryFileStore, getURLStreamHandlerFactory, hasProvider, removeProvider, resolveFile, resolveFile, resolveFile, resolveFile, resolveFile, resolveFile, resolveFile, resolveName, resolveName, resolveURI, setBaseFile, setBaseFile, setCacheStrategy, setDefaultProvider, setFileContentInfoFactory, setFileObjectDecorator, setFilesCache, setLogger, setReplicator, setTemporaryFileStore, toFileObject
-
Field Details
-
CONFIG_RESOURCE
- See Also:
-
PLUGIN_CONFIG_RESOURCE
- See Also:
-
configUri
-
classLoader
-
-
Constructor Details
-
StandardFileSystemManager
public StandardFileSystemManager()
-
-
Method Details
-
setConfiguration
Sets the configuration file for this manager.- Parameters:
configUri
- The URI for this manager.
-
setConfiguration
Sets the configuration file for this manager.- Parameters:
configUri
- The URI forthis manager.
-
setClassLoader
Sets the ClassLoader to use to load the providers. Default is to use the ClassLoader that loaded this class.- Parameters:
classLoader
- The ClassLoader.
-
init
Initializes this manager. Adds the providers and replicator.- Overrides:
init
in classDefaultFileSystemManager
- Throws:
FileSystemException
- if an error occurs.
-
configurePlugins
Scans the classpath to find any droped plugin.The plugin-description has to be in
/META-INF/vfs-providers.xml
.- Throws:
FileSystemException
- if an error occurs.
-
findClassLoader
Returns a class loader or null since some Java implementation is null for the bootstrap class loader.- Returns:
- A class loader or null since some Java implementation is null for the bootstrap class loader.
-
createDefaultFileReplicator
-
configure
Configures this manager from an XML configuration file.- Parameters:
configUri
- The URI of the configuration.- Throws:
FileSystemException
- if an error occus.
-
configure
Configures this manager from an XML configuration file.- Parameters:
configUri
- The URI of the configuration.configStream
- An InputStream containing the configuration.- Throws:
FileSystemException
- if an error occurs.
-
createDocumentBuilder
Configure and create a DocumentBuilder- Returns:
- A DocumentBuilder for the configuration.
- Throws:
ParserConfigurationException
- if an error occurs.
-
configure
Configures this manager from an parsed XML configuration file- Parameters:
config
- The configuration Element.- Throws:
FileSystemException
- if an error occurs.
-
addExtensionMap
Adds an extension map.- Parameters:
map
- containing the Elements.
-
addMimeTypeMap
Adds a mime-type map.- Parameters:
map
- containing the Elements.
-
addProvider
Adds a provider from a provider definition.- Parameters:
providerDef
- the provider definitionisDefault
- true if the default should be used.- Throws:
FileSystemException
- if an error occurs.
-
addOperationProvider
Adds a operationProvider from a operationProvider definition.- Throws:
FileSystemException
-
findClass
Tests if a class is available. -
getRequiredClasses
Extracts the required classes from a provider definition. -
getRequiredSchemes
Extracts the required schemes from a provider definition. -
getSchemas
Extracts the schema names from a provider definition. -
getValidClassLoader
-
validateClassLoader
-
createInstance
Creates a provider.- Throws:
FileSystemException
-
loadClass
Load a class from different class loaders.- Throws:
ClassNotFoundException
- if lastloadClass
failed.- See Also:
-
enumerateResources
Enumerates resources from different class loaders.- Throws:
IOException
- ifgetResource
failed.- See Also:
-