Class StandardFileSystemManager

java.lang.Object
org.apache.commons.vfs2.impl.DefaultFileSystemManager
org.apache.commons.vfs2.impl.StandardFileSystemManager
All Implemented Interfaces:
AutoCloseable, 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 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".

  • Field Details

  • Constructor Details

    • StandardFileSystemManager

      public StandardFileSystemManager()
  • Method Details

    • setConfiguration

      public void setConfiguration(String configUri)
      Sets the configuration file for this manager.
      Parameters:
      configUri - The URI for this manager.
    • setConfiguration

      public void setConfiguration(URL configUri)
      Sets the configuration file for this manager.
      Parameters:
      configUri - The URI forthis manager.
    • setClassLoader

      public void setClassLoader(ClassLoader classLoader)
      Sets the ClassLoader to use to load the providers. Default is to use the ClassLoader that loaded this class.
      Parameters:
      classLoader - The ClassLoader.
    • init

      public void init() throws FileSystemException
      Initializes this manager. Adds the providers and replicator.
      Overrides:
      init in class DefaultFileSystemManager
      Throws:
      FileSystemException - if an error occurs.
    • 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 - if an error occurs.
    • findClassLoader

      private ClassLoader 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

      protected DefaultFileReplicator createDefaultFileReplicator()
    • configure

      private void configure(URL configUri) throws FileSystemException
      Configures this manager from an XML configuration file.
      Parameters:
      configUri - The URI of the configuration.
      Throws:
      FileSystemException - if an error occus.
    • configure

      private void configure(String configUri, InputStream configStream) throws FileSystemException
      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

      private DocumentBuilder createDocumentBuilder() throws ParserConfigurationException
      Configure and create a DocumentBuilder
      Returns:
      A DocumentBuilder for the configuration.
      Throws:
      ParserConfigurationException - if an error occurs.
    • configure

      private void configure(Element config) throws FileSystemException
      Configures this manager from an parsed XML configuration file
      Parameters:
      config - The configuration Element.
      Throws:
      FileSystemException - if an error occurs.
    • addExtensionMap

      private void addExtensionMap(Element map)
      Adds an extension map.
      Parameters:
      map - containing the Elements.
    • addMimeTypeMap

      private void addMimeTypeMap(Element map)
      Adds a mime-type map.
      Parameters:
      map - containing the Elements.
    • addProvider

      private void addProvider(Element providerDef, boolean isDefault) throws FileSystemException
      Adds a provider from a provider definition.
      Parameters:
      providerDef - the provider definition
      isDefault - true if the default should be used.
      Throws:
      FileSystemException - if an error occurs.
    • addOperationProvider

      private void addOperationProvider(Element providerDef) throws FileSystemException
      Adds a operationProvider from a operationProvider definition.
      Throws:
      FileSystemException
    • findClass

      private boolean findClass(String className)
      Tests if a class is available.
    • getRequiredClasses

      private String[] getRequiredClasses(Element providerDef)
      Extracts the required classes from a provider definition.
    • getRequiredSchemes

      private String[] getRequiredSchemes(Element providerDef)
      Extracts the required schemes from a provider definition.
    • getSchemas

      private String[] getSchemas(Element provider)
      Extracts the schema names from a provider definition.
    • getValidClassLoader

      private ClassLoader getValidClassLoader(Class<?> clazz)
    • validateClassLoader

      private ClassLoader validateClassLoader(ClassLoader clazzLoader, Class<?> clazz)
    • createInstance

      private Object createInstance(String className) throws FileSystemException
      Creates a provider.
      Throws:
      FileSystemException
    • loadClass

      private Class<?> loadClass(String className) throws ClassNotFoundException
      Load a class from different class loaders.
      Throws:
      ClassNotFoundException - if last loadClass failed.
      See Also:
    • enumerateResources

      private Enumeration<URL> enumerateResources(String name) throws IOException
      Enumerates resources from different class loaders.
      Throws:
      IOException - if getResource failed.
      See Also: