[jboss-dev-forums] [Design of POJO Server] - Re: VFS Permissions - JBMICROCONT-149
adrian@jboss.org
do-not-reply at jboss.com
Tue Nov 11 05:50:32 EST 2008
"alesj" wrote : "alesj" wrote : "adrian at jboss.org" wrote :
| | | This requires something in the VFS, my suggestion was to add
| | | VFSUtils.getRealURL(vfsFile);
| | |
| | Should I hold off VFS 2.0.0.GA until these features get into VFS?
| I see Anil already added this to VFS.
| But it looks wrong. ;-)
|
That's the problem with quick and dirty. ;-)
I said it should be
VFSUtils.getRealURL(vfsFile) above but Anil has done URL.
What should happen is this uses the implemented details of the VirtualFile
to delegate the request to the vfs handler.
Only the protocol specific handler knows how it maps its urls to a real url.
Its called object orientated programming. :-)
The list of if statements is the clue.
if you have to write code like (which is also incredibly inefficient)
| if(vfsURL.getPath().endsWith("jar"))
| ...
| if(vfsURL.getProtocol().startsWith("vfsfile"))
| ...
| if(vfsURL.getProtocol().startsWith("vfszip"))
| ...
| etc.
|
You're almost certainly doing something wrong.
Correct would be something like:
| public URL getRealURL(VirtualFile file)
| {
| // public methods should always check parameters to give useful error messages
| if (file == null)
| throw new IllegalArgumentException("null file);
| VirtualFileHandler handler = file.getHandler();
| return handler.getRealURL(); // NEW METHOD
| }
|
But at least its in the right project now. ;-)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4188419#4188419
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4188419
More information about the jboss-dev-forums
mailing list