Question regarding extensibility

Marcel Ammerlaan marcel-snoracle-nio at dyskolus.com
Wed Feb 3 12:00:14 PST 2010


Hello,

I'm trying out the new java.nio.file.* as an alternative to Apache VFS.
One striking omission however is the ability to add new filesystems 
dynamically:
the list of providers is initialized once which makes it impossible to 
add new
filesystems dynamically. I've currently added this feature in a crude 
fashion like this:

public static boolean addFileSystemProvider(FileSystemProvider prov) {
       synchronized(lock) {
           List<FileSystemProvider> providers = installedProviders();
           String newScheme = prov.getScheme();
           for(FileSystemProvider fsp : providers) {
               if(fsp.getScheme().equalsIgnoreCase(newScheme)) {
                   return false;
               }
           }
           installedProviders.add(prov);
           return true;
       }
   }

(and changed the list to be synchronized instead of read-only)

Meaning that I'll not overwrite existing system provided providers but 
at least can add
new ones (and then of course deletion would be nice as well ;-)

Are there any plans to add this little feature to make the plugability 
of the API
more usefull?

Regards,

Marcel Ammerlaan.




More information about the nio-discuss mailing list