Issue implementing FileSystemProvider.getScheme()

Alan Bateman Alan.Bateman at oracle.com
Sun May 29 00:52:51 PDT 2011


Christian Schlichtherle wrote:
> Hi Alan,
>
> I have a troublesome issue with implementing a FileSystemProvider for
> TrueZIP:
>
> The problem is that FileSystemProvider.getScheme() can only return a single
> scheme. However, TrueZIP supports plenty of schemes which are discovered at
> runtime. So I cannot add a FileSystemProvider implementation class name for
> each scheme in META-INF/services/java.nio.file.spi.FileSystemProvider at
> compile time.
>
> The workaround I am using now is a dirty hack:
>   
The intended way to deploy a virtual file system provider is to choose 
one URI scheme, say "vfs", and have it be the factory for a single 
virtual file system instance. So for what you are doing then possible 
URIs might be be vfs:///, vfs://dir/, vfs:///dir/foo.jar/, 
vfs:///dir/foo.jar/bar.rar/, vfs:///dir/foo.jar/bar.rar/entry, etc. Your 
virtual file system provider can delegate to other installed (or 
dynamically located) providers that use other URI schemes but they just 
aren't exposed to the users of the API.

Going further, if you can eventually eliminate the virtual file system 
provider's dependency on the java.io classes mentioned in the other 
thread, then you can experiment with moving to the "file" scheme and 
making your provider the default provider.  That would make for a nice 
demonstration of everything working together.

-Alan.


More information about the nio-discuss mailing list