AW: Dynamic loading of FileSystemProvider instances

Alan Bateman Alan.Bateman at oracle.com
Tue Jun 7 01:27:58 PDT 2011


Christian Schlichtherle wrote:
> :
> This method uses a ServiceLoader which loads the FileSystemProvider class
> names from a resource on the class path and instantiates one instance for
> each line entry, right?
>   
Yes, that's right.

> Well, that's the problem: The resource is created at compile time, so
> whatever I put in there I have no chance to determine the number of
> FileSystemProvider instances at run time.
>
> However, I really need a way to do this because the FileSystemProvider class
> is limited to exactly one scheme. However, TrueZIP supports an arbitrary
> number of schemes and I cannot predetermine them in a reliable way. For
> example, at run time I might figure that I need to have a FileSystemProvider
> for the following schemes:
>
> "tzp.file" for mapping Path URI "file:/foo.zip" to FsPath URI
> "zip:file:/foo.zip!/".
>
> "tzp.file.c" for mapping "file:///C:/foo.tar" to "tar:file:/C:/foo.tar!/"
>
> "tzp.file.d" for mapping "file:///D:/foo.tar.bz2" to
> "tar.bz2:file:/D:/foo.tar.bz2!/"
>
> "tzp.http" for mapping "http://download.oracle.com/everyting.zip" to
> "zip:http://download.oracle.com/everything.zip!/"
>
> "tzp.https" for mapping "https://download.oracle.com/everyting.zip" to
> "zip:https://download.oracle.com/everything.zip!/"
>
> etc etc...
>
> I hope this makes it clear now. This is really an important issue. I need to
> have a chance to figure the number of FileSystemProvider instances at run
> time, otherwise TrueZIP's FileSystemProvider implementation would be
> seriously crippled because I can use only one scheme per FileSystemProvider
> instance.
>
>   
I don't think I understand this. It looks like you are dynamically 
generate a URI scheme per mount point and it's not clear (to me anyway) 
if this means you have a file system provider per mount point (which 
doesn't make sense). Are these URIs internal to your provider as they 
doesn't seem to be something that should be exposed to anyone using this 
API?

-Alan.


More information about the nio-discuss mailing list