org.apache.commons.vfs.impl
Class StandardFileSystemManager

java.lang.Object
  extended by org.apache.commons.vfs.impl.DefaultFileSystemManager
      extended by org.apache.commons.vfs.impl.StandardFileSystemManager
All Implemented Interfaces:
FileSystemManager

public class StandardFileSystemManager
extends DefaultFileSystemManager

A FileSystemManager that configures itself from an XML (Default: providers.xml) configuration file.
Certain providers are only loaded and available if the dependend 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".

Version:
$Revision: 480428 $ $Date: 2006-11-29 07:15:24 +0100 (Mi, 29 Nov 2006) $
Author:
Adam Murdoch

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.commons.vfs.impl.DefaultFileSystemManager
DefaultFileSystemManager.VfsStreamHandlerFactory
 
Field Summary
private  java.lang.ClassLoader classLoader
           
private static java.lang.String CONFIG_RESOURCE
           
private  java.net.URL configUri
           
private  org.apache.commons.logging.Log log
           
private static java.lang.String PLUGIN_CONFIG_RESOURCE
           
 
Constructor Summary
StandardFileSystemManager()
           
 
Method Summary
private  void addExtensionMap(org.w3c.dom.Element map)
          Adds an extension map.
private  void addMimeTypeMap(org.w3c.dom.Element map)
          Adds a mime-type map.
private  void addOperationProvider(org.w3c.dom.Element providerDef)
          Adds a operationProvider from a operationProvider definition.
private  void addProvider(org.w3c.dom.Element providerDef, boolean isDefault)
          Adds a provider from a provider definition.
private  void configure(org.w3c.dom.Element config)
          Configures this manager from an parsed XML configuration file
private  void configure(java.lang.String configUri, java.io.InputStream configStream)
          Configures this manager from an XML configuration file.
private  void configure(java.net.URL configUri)
          Configures this manager from an XML configuration file.
protected  void configurePlugins()
          Scans the classpath to find any droped plugin.
The plugin-description has to be in /META-INF/vfs-providers.xml
protected  DefaultFileReplicator createDefaultFileReplicator()
           
private  javax.xml.parsers.DocumentBuilder createDocumentBuilder()
          Configure and create a DocumentBuilder
private  java.lang.Object createInstance(java.lang.String className)
          Creates a provider.
private  boolean findClass(java.lang.String className)
          Tests if a class is available.
private  java.lang.ClassLoader findClassLoader()
           
private  java.lang.String[] getRequiredClasses(org.w3c.dom.Element providerDef)
          Extracts the required classes from a provider definition.
private  java.lang.String[] getRequiredSchemes(org.w3c.dom.Element providerDef)
          Extracts the required schemes from a provider definition.
private  java.lang.String[] getSchemas(org.w3c.dom.Element provider)
          Extracts the schema names from a provider definition.
 void init()
          Initializes this manager.
 void setClassLoader(java.lang.ClassLoader classLoader)
          Sets the ClassLoader to use to load the providers.
 void setConfiguration(java.lang.String configUri)
          Sets the configuration file for this manager.
 void setConfiguration(java.net.URL configUri)
          Sets the configuration file for this manager.
 
Methods inherited from class org.apache.commons.vfs.impl.DefaultFileSystemManager
_closeFileSystem, addExtensionMap, addMimeTypeMap, addOperationProvider, addOperationProvider, addProvider, addProvider, canCreateFileSystem, close, closeFileSystem, createFileSystem, createFileSystem, createVirtualFileSystem, createVirtualFileSystem, freeUnusedResources, getBaseFile, getCacheStrategy, getFileContentInfoFactory, getFileObjectDecorator, getFileObjectDecoratorConst, getFilesCache, getFileSystemConfigBuilder, getLogger, getOperationProviders, getProviderCapabilities, getReplicator, getSchemes, getTemporaryFileStore, getURLStreamHandlerFactory, hasProvider, resolveFile, resolveFile, resolveFile, resolveFile, resolveFile, resolveName, resolveName, resolveURI, setBaseFile, setBaseFile, setCacheStrategy, setDefaultProvider, setFileContentInfoFactory, setFileObjectDecorator, setFilesCache, setLogger, setReplicator, setTemporaryFileStore, toFileObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private org.apache.commons.logging.Log log

CONFIG_RESOURCE

private static final java.lang.String CONFIG_RESOURCE
See Also:
Constant Field Values

PLUGIN_CONFIG_RESOURCE

private static final java.lang.String PLUGIN_CONFIG_RESOURCE
See Also:
Constant Field Values

configUri

private java.net.URL configUri

classLoader

private java.lang.ClassLoader classLoader
Constructor Detail

StandardFileSystemManager

public StandardFileSystemManager()
Method Detail

setConfiguration

public void setConfiguration(java.lang.String configUri)
Sets the configuration file for this manager.


setConfiguration

public void setConfiguration(java.net.URL configUri)
Sets the configuration file for this manager.


setClassLoader

public void setClassLoader(java.lang.ClassLoader classLoader)
Sets the ClassLoader to use to load the providers. Default is to use the ClassLoader that loaded this class.


init

public void init()
          throws FileSystemException
Initializes this manager. Adds the providers and replicator.

Overrides:
init in class DefaultFileSystemManager
Throws:
FileSystemException

configurePlugins

protected void configurePlugins()
                         throws FileSystemException
Scans the classpath to find any droped plugin.
The plugin-description has to be in /META-INF/vfs-providers.xml

Throws:
FileSystemException

findClassLoader

private java.lang.ClassLoader findClassLoader()

createDefaultFileReplicator

protected DefaultFileReplicator createDefaultFileReplicator()

configure

private void configure(java.net.URL configUri)
                throws FileSystemException
Configures this manager from an XML configuration file.

Throws:
FileSystemException

configure

private void configure(java.lang.String configUri,
                       java.io.InputStream configStream)
                throws FileSystemException
Configures this manager from an XML configuration file.

Throws:
FileSystemException

createDocumentBuilder

private javax.xml.parsers.DocumentBuilder createDocumentBuilder()
                                                         throws javax.xml.parsers.ParserConfigurationException
Configure and create a DocumentBuilder

Throws:
javax.xml.parsers.ParserConfigurationException

configure

private void configure(org.w3c.dom.Element config)
                throws FileSystemException
Configures this manager from an parsed XML configuration file

Throws:
FileSystemException

addExtensionMap

private void addExtensionMap(org.w3c.dom.Element map)
Adds an extension map.


addMimeTypeMap

private void addMimeTypeMap(org.w3c.dom.Element map)
Adds a mime-type map.


addProvider

private void addProvider(org.w3c.dom.Element providerDef,
                         boolean isDefault)
                  throws FileSystemException
Adds a provider from a provider definition.

Throws:
FileSystemException

addOperationProvider

private void addOperationProvider(org.w3c.dom.Element providerDef)
                           throws FileSystemException
Adds a operationProvider from a operationProvider definition.

Throws:
FileSystemException

findClass

private boolean findClass(java.lang.String className)
Tests if a class is available.


getRequiredClasses

private java.lang.String[] getRequiredClasses(org.w3c.dom.Element providerDef)
Extracts the required classes from a provider definition.


getRequiredSchemes

private java.lang.String[] getRequiredSchemes(org.w3c.dom.Element providerDef)
Extracts the required schemes from a provider definition.


getSchemas

private java.lang.String[] getSchemas(org.w3c.dom.Element provider)
Extracts the schema names from a provider definition.


createInstance

private java.lang.Object createInstance(java.lang.String className)
                                 throws FileSystemException
Creates a provider.

Throws:
FileSystemException