[jboss-dev-forums] [Design of POJO Server] - Re: VFS Permissions - JBMICROCONT-149
anil.saldhana@jboss.com
do-not-reply at jboss.com
Tue Nov 11 10:12:13 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. ;-)
|
|
| | /**
| | * Get the Real URL
| | * @param vfsURL
| | * @return
| | * @throws Exception
| | */
| | public static URL getRealURL(URL vfsURL) throws Exception
| | {
| | if(vfsURL.getPath().endsWith("jar"))
| | {
| | String urlStr = "jar:" + FILE_PROTOCOL + ":" + vfsURL.getPath() + JAR_URL_SEPARATOR;
| | return new URL(urlStr);
| | }
| |
| | if(vfsURL.getProtocol().startsWith("vfsfile"))
| | return new URL(FILE_PROTOCOL, vfsURL.getHost(), vfsURL.getPort(), vfsURL.getFile());
| |
| | if(vfsURL.getProtocol().startsWith("vfszip"))
| | {
| | String urlStr = vfsURL.toExternalForm();
| | //nested file
| | int indexJar = urlStr.indexOf(".jar");
| | String beforejar = urlStr.substring("vfszip:".length(), urlStr.indexOf(".jar"));
| | String afterjar = urlStr.substring(indexJar + 1 + ".jar".length());
| | return new URL("jar:file:" + beforejar + ".jar " + JAR_URL_SEPARATOR + afterjar);
| | }
| | if(log.isTraceEnabled())
| | log.trace("getRealURL did not have a match for:"+vfsURL.toExternalForm());
| | return vfsURL;
| | }
| |
|
| First some simple code critique.
|
| If you add something to project you don't sustain,
| be fair and add javadocs as it should be done.
| Since this is probably gonna be called for every class we load,
| some more constants won't kill you.
| Dunno how much optimization javac puts on "vfszip."length() and repeated ".jar".
|
| Tests should be more exhaustive.
| As I see some extra space after last ".jar that's probably not supposed to be there.
| Dunno how this would work.
|
| But in general, jar/zip handling is completely broken.
| First, it should be the same code that handles it,
| since, although we currently use vfszip, user can still fall back to old vfsjar handling.
| And they are both the same as far as feature set goes (it's just that we have winz lock problems on vfsjar).
| But the biggest problem I see is how are you gonna handle multiple nested jars.
| Dunno what's the proper/real url for those, but I very much doubt it's how your code does it.
| I guess this would have to be an impl of VirtualFileHandlers, not just VFSUtils.
|
| Conclusion.
| Either this is done right, or it goes out.
| I'll leave it for now, but will check on it before I do 2.0.0.GA.
|
| If you need any help on writing this, open a new forum post.
| And I'll see what can be done. ;-)
Thanks for your comments. I already had generated the constants. I was unable to put it back as I forgot before I slept and you rolled back.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4188485#4188485
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4188485
More information about the jboss-dev-forums
mailing list