You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Andrew Barnes <an...@geni.com.au> on 2006/03/08 03:34:56 UTC

[vfs] usage questions

Hi

Just wanted to ask some basic usage questions for using Commons VFS in a
J2EE app.

1) I call VFS.getManager() from a constructor of my file system wrapper
class, and use that one FileSystemManager instance every time a CommonsVFS
operation is executed. Is this the correct usage? Or should I get a
different FileSystemManager for each request. I notice that the close()
method is not on the FileSystemManager interface.

2) If you can use the same FileSystemManager instance across multiple calls,
do you need to periodically free unused resources?

3) Do you only need to close a FileObject when you have retrieved the
content, or should close it after any operation.

Sorry if these seem like silly questions, but the documentation seems a
little unclear. It says in the documentation that "You should make sure that
you call close() on the manager when you are finished with it." Is this for
all methods of retrieval and configuration, or only when you create and
configure it programmatically.

Regards
Andy



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


Re: [vfs] ram filesystem

Posted by Edgar Poce <ed...@gmail.com>.
Hi Gavin,

>     (2) The Commons-VFS "Download" web pages notes an optional
>         dependency on  Commons-Collections (for LRU Cache), but
>         the RamFileSystem code requires this library.
>

I'll prepare a patch ASAP, thanks for reporting the issue.

br,
edgar

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


Re: [vfs] ram filesystem

Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi!
>    (1) "providers.xml" hasn't learned about this filesystem yet
>        (easy to fix with local /META-INF/vfs-providers.xml)
:-) what a shame

Its added to the core now.

Thanks for reporting it.

Ciao,
Mario


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


[vfs] ram filesystem

Posted by Gavin Eadie <ga...@umich.edu>.
I noticed the arrival of the memory filesystem and thought I'd look at it.
It's early days, and this may all be in work, but I noticed two things:

    (1) "providers.xml" hasn't learned about this filesystem yet
        (easy to fix with local /META-INF/vfs-providers.xml)

    (2) The Commons-VFS "Download" web pages notes an optional
        dependency on  Commons-Collections (for LRU Cache), but
        the RamFileSystem code requires this library.

Re: [vfs] usage questions

Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi!
> 1) I call VFS.getManager() from a constructor of my file system wrapper
> class, and use that one FileSystemManager instance every time a CommonsVFS
> operation is executed. Is this the correct usage? Or should I get a
> different FileSystemManager for each request. I notice that the close()
> method is not on the FileSystemManager interface.
>   
Using VFS.getManager() is the correct use, and a "soft reference" cache
tries to keep memory clean.
I use it in our web-app the same way.
Though, there is noting bad with instantiating the FileSystemManager
manual for every request - beside the fact that it is a hevyweight
operation.

> 2) If you can use the same FileSystemManager instance across multiple calls,
> do you need to periodically free unused resources?
>   
In theory not, but VFS creates a vfs_temp directory where you should
setup some cron job to remove old files.
Sometimes (or often ;-) ) not all files are deleted.
> 3) Do you only need to close a FileObject when you have retrieved the
> content, or should close it after any operation.
>   
Its sufficient to close a FileObject after you have done some stream
(create file/output/input) operations. For this you can use the .close()
method of the stream instance.
Though, when you use the VFS.getManager() stuff its sometimes required
(e.g. when you monitor a file) to close() the FileObject to synchronize
the internal state with the filesystem.

> Sorry if these seem like silly questions, but the documentation seems a
> little unclear. It says in the documentation that "You should make sure that
> you call close() on the manager when you are finished with it." Is this for
> all methods of retrieval and configuration, or only when you create and configure it programmatically.
>
>   
If you use a single instance for all threads (VFS.getManager()) then you
should NOT call close() as this will affect other threads. If you create
your own manager on a e.g. per-request basis you are safe to call
close() on the manager, and thus you can be sure all resources were freed.

Hope that helps!
Ciao,
Mario


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