Dynamic loading of FileSystemProvider instances

Christian Schlichtherle christian at schlichtherle.de
Mon Jun 6 03:10:21 PDT 2011


Hi Alan,

we recently discussed that I have a need to determine the NIO.2
FileSystemProvider instances at run time. Because this is not possible, you
suggested I should introduce one VFS scheme for my TrueZIP
TFileSystemProvider. For example, the NIO.2 Path URI "tzp:/archive.zip"
should get identified by my TrueZIP TFilesystemProvider and internally
rewritten to the TrueZIP FsPath URI "zip:file:/archive.zip!/".

While this is certainly possible, it still limits my implementation: The
issue is that I need to determine a TrueZIP FsMountPoint URI for rewriting
the NIO.2 Path URI. In the example above, this is "file:/". However, on
Windows, it could be "file:/C:/" or "file:/D:/" or whatever. In TrueZIP, it
could even be "http://somehost/" or "http://someotherhost/base/" or
whatever. It could even be an entirely different scheme, depending on the
file system driver.

To overcome this, I need a way to determine the NIO.2 FileSystemProvider
instances at run time. To make minimal impact on the current NIO.2 API, I
suggest the following quick draft:

<code>
package java.nio.file.spi;

public interface FileSystemProviderCatalogue extends
Iterable<FileSystemProvider> {
}
</code>

You could then simply use java.util.ServiceLoader to locate
FileSystemProviderCatalogue instances on the run time class path while I
could happily implement the iterator to figure the TFileSystemProvider
instances I need.

Regards,
Christian




More information about the nio-discuss mailing list