if (protocol == null) {
throw new MalformedURLException("Unsupported virtual filesystem protocol '" + url.getProtocol() + "'");
}
// create a new instance of the provider and return it
BaseRemoteFileSystem vfs = null;
try {
Class vfsClass = protocol.getProvider();
// create a new instance, cast it
vfs = (BaseRemoteFileSystem)vfsClass.newInstance();
} catch (Exception e) {
throw new FileSystemException("Could not create instance of " + protocol.getProvider(), e);
}
// setup any common properties
vfs.setURL(url);
vfs.setProtocol(protocol);
// validate the properties
vfs.validateURL();
return vfs;
}