commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Johan Lindquist" <jo...@kawoo.co.uk>
Subject [VFS] FileSystem close
Date Fri, 02 Jul 2004 16:20:48 GMT
Hi,

I asked about this a little while ago - when you resolve a file for a SFTP  
url, the SFTP file system maintains the session until the file manager is  
closed - the solution you propsed (see below) works well, but this will  
not work if I try to use this in a multi-threaded environment.

FileSystemOptions fso = new FileSystemOptions();
SftpFileSystemConfigBuilder.getInstance().setUserInfo(fso, new  
TrustEveryoneUserInfo());

FileObject inFile = fsManager.resolveFile("sftp://someurl", fso);

// do something with the file

StandardFileSystemManager fsm = (StandardFileSystemManager)  
VFS.getManager();
fsm.close();

A step closer (if i understand the arch. correctly) would be to expose the  
close method (as available on the SFTPFileSystem class for example) in the  
FileSystem interface.  This allow you to retrieve the file system for the  
file object being accessed and manually close it.  It is not the ideal  
solution, but would free the jsch session being held in the background.

Does this have any side-effects i haven't thought about - one i can think  
of is (again) concurrent access to the same filesystem.  So, maybe the  
file system could close itself only if there are no more references to  
files within it?

So, something like this:

FileSystemOptions fso = new FileSystemOptions();
SftpFileSystemConfigBuilder.getInstance().setUserInfo(fso, new  
TrustEveryoneUserInfo());

FileObject inFile = fsManager.resolveFile("sftp://someurl", fso);

// do something with the file

fs = inFile.getFileSystem();
fs.close();

What are the general thoughts about this?

Regards,

Johan

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message