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 ClassLoaderprivate static final Stringprivate URLprivate static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddExtensionMap(Element map) Adds an extension map.private voidaddMimeTypeMap(Element map) Adds a mime-type map.private voidaddOperationProvider(Element providerDef) Adds a operationProvider from a operationProvider definition.private voidaddProvider(Element providerDef, boolean isDefault) Adds a provider from a provider definition.private voidConfigures this manager from an XML configuration file.private voidConfigures this manager from a parsed XML configuration fileprotected voidScans the classpath to find any dropped plugin.protected DefaultFileReplicatorGets a new DefaultFileReplicator.private DocumentBuilderConfigure and create a DocumentBuilderprivate ObjectcreateInstance(String className) Creates a provider.private Enumeration<URL> enumerateResources(String name) Enumerates resources from different class loaders.private booleanTests if a class is available.private ClassLoaderReturns 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 ClassLoadergetValidClassLoader(Class<?> clazz) voidinit()Initializes this manager.private Class<?> Load a class from different class loaders.voidsetClassLoader(ClassLoader classLoader) Sets the ClassLoader to use to load the providers.voidsetConfiguration(String configUri) Sets the configuration file for this manager.voidsetConfiguration(URL configUri) Sets the configuration file for this manager.private ClassLoadervalidateClassLoader(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, toFileObjectMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.commons.vfs2.FileSystemManager
toFileObject
-
Field Details
-
CONFIG_RESOURCE
- See Also:
-
PLUGIN_CONFIG_RESOURCE
- See Also:
-
configUri
-
classLoader
-
-
Constructor Details
-
StandardFileSystemManager
public StandardFileSystemManager()Constructs a new instance.
-
-
Method Details
-
addExtensionMap
Adds an extension map.- Parameters:
map- containing the Elements.
-
addMimeTypeMap
Adds a mime-type map.- Parameters:
map- containing the Elements.
-
addOperationProvider
Adds a operationProvider from a operationProvider definition.- Throws:
FileSystemException
-
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.
-
configure
Configures this manager from a parsed XML configuration file- Parameters:
config- The configuration Element.- Throws:
FileSystemException- if an error occurs.
-
configure
Configures this manager from an XML configuration file.- Parameters:
configUri- The URI of the configuration.- Throws:
FileSystemException- if an error occurs.
-
configurePlugins
Scans the classpath to find any dropped plugin.The plugin-description has to be in
/META-INF/vfs-providers.xml.- Throws:
FileSystemException- if an error occurs.
-
createDefaultFileReplicator
Gets a new DefaultFileReplicator.- Returns:
- a new DefaultFileReplicator.
-
createDocumentBuilder
Configure and create a DocumentBuilder- Returns:
- A DocumentBuilder for the configuration.
- Throws:
ParserConfigurationException- if an error occurs.
-
createInstance
Creates a provider.- Throws:
FileSystemException
-
enumerateResources
Enumerates resources from different class loaders.- Throws:
IOException- ifgetResourcefailed.- See Also:
-
findClass
Tests if a class is available. -
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.
-
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
-
init
Initializes this manager. Adds the providers and replicator.- Overrides:
initin classDefaultFileSystemManager- Throws:
FileSystemException- if an error occurs.
-
loadClass
Load a class from different class loaders.- Throws:
ClassNotFoundException- if lastloadClassfailed.- See Also:
-
setClassLoader
Sets the ClassLoader to use to load the providers. Default is to use the ClassLoader that loaded this class.- Parameters:
classLoader- The ClassLoader.
-
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 for this manager.
-
validateClassLoader
-