commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject Re: [vfs] res: protocol issue (possible enhancement?)
Date Thu, 04 Aug 2005 14:46:40 GMT
Quoting Mario Ivankovits <mario@ops.co.at>:

> Jacob Kjome wrote:
> > FileSystemManager fsManager = VFS.getManager();
> > FileObject pkg = fsManager.resolveFile( "res:com/mycompany/mypackage" );
> >
> > And my classpath looked like the following (with both "com" in the
> > current directory and that same package in my.jar)...
> >
> > .;my.jar
> >
> > I'd need the FileObject to represent multiple paths so when I can
> > pkg.getChildren(), it represents resources from both package paths,
> > not just the first one it finds, which is the current case with the
> > "res" scheme.  Is there an existing example FileObject impl that
> > represents multiple paths?  If not, how would I go about this?  I just
> > need a little direction.
> Oh yes, thats a problem.
> One solution could be to create a CompositeFileObject. This hold
> multiple FileObjects and merges all outputs (getChildren, findFiles, ...)
>

I thought about that, but I've a bit confused.  I would have expected the "pkg"
FileObject to be a UrlFileObject, but it was a LocalFile (shouldn't this be
LocalFileObject, BTW?).  That's based on the ResourceFileSystemConfigBuilder
defining its config class as UrlFileSystem.class.

I'm also a bit confused at how the ResourceFileProvider.findFile() makes this
call...

FileObject fo =
getContext().getFileSystemManager().resolveFile(url.toExternalForm());

But if you look at DefaultFileSystemManager.resolveFile(), it seems to simply
call the provider's findFile() method...

// Extract the scheme
        final String scheme = UriParser.extractScheme(uri);
        if (scheme != null)
        {
// An absolute URI - locate the provider
            final FileProvider provider = (FileProvider) providers.get(scheme);
            if (provider != null)
            {
                return provider.findFile(baseFile, uri, fileSystemOptions);
            }

How is this not circular?  I must be missing something.  Are there any docs that
describe the design of VFS rather than just how to use it?


> But there are a couple of problems, e.g. what if a entry is a file in
> one jar and a directory in another? What should the CompositeFileObject
> say when using getType() then?
>

I find that to be an unlikely circumstance.  However, in that case we can either
throw an exception or treat it as a directory if at least one of the resources
is a directory and return any that aren't directories in the getChildren().


Jake

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




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


Mime
View raw message