Class StandardFileSystemManager

  • All Implemented Interfaces:
    java.lang.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 Detail

      • 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.
        Parameters:
        configUri - The URI for this manager.
      • setConfiguration

        public void setConfiguration​(java.net.URL configUri)
        Sets the configuration file for this manager.
        Parameters:
        configUri - The URI forthis 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.
        Parameters:
        classLoader - The ClassLoader.
      • 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 java.lang.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.
      • configure

        private void configure​(java.net.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​(java.lang.String configUri,
                               java.io.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 javax.xml.parsers.DocumentBuilder createDocumentBuilder()
                                                                 throws javax.xml.parsers.ParserConfigurationException
        Configure and create a DocumentBuilder
        Returns:
        A DocumentBuilder for the configuration.
        Throws:
        javax.xml.parsers.ParserConfigurationException - if an error occurs.
      • configure

        private void configure​(org.w3c.dom.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​(org.w3c.dom.Element map)
        Adds an extension map.
        Parameters:
        map - containing the Elements.
      • addMimeTypeMap

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

        private void addProvider​(org.w3c.dom.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​(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.
      • getValidClassLoader

        private java.lang.ClassLoader getValidClassLoader​(java.lang.Class<?> clazz)
      • validateClassLoader

        private java.lang.ClassLoader validateClassLoader​(java.lang.ClassLoader clazzLoader,
                                                          java.lang.Class<?> clazz)
      • loadClass

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

        private java.util.Enumeration<java.net.URL> enumerateResources​(java.lang.String name)
                                                                throws java.io.IOException
        Enumerates resources from different class loaders.
        Throws:
        java.io.IOException - if getResource failed.
        See Also:
        findClassLoader()