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()
      Constructs a new instance.
  • Method Details

    • 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.
    • addOperationProvider

      private void addOperationProvider(Element providerDef) throws FileSystemException
      Adds a operationProvider from a operationProvider definition.
      Throws:
      FileSystemException
    • 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.
    • configure

      private void configure(Element config) throws FileSystemException
      Configures this manager from a parsed XML configuration file
      Parameters:
      config - The configuration Element.
      Throws:
      FileSystemException - if an error occurs.
    • 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 occurs.
    • configurePlugins

      protected void configurePlugins() throws FileSystemException
      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

      protected DefaultFileReplicator createDefaultFileReplicator()
      Gets a new DefaultFileReplicator.
      Returns:
      a new DefaultFileReplicator.
    • createDocumentBuilder

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

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

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

      private boolean findClass(String className)
      Tests if a class is available.
    • 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.
    • 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)
    • 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.
    • loadClass

      private Class<?> loadClass(String className) throws ClassNotFoundException
      Load a class from different class loaders.
      Throws:
      ClassNotFoundException - if last loadClass failed.
      See Also:
    • 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.
    • 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 for this manager.
    • validateClassLoader

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