About a month ago I did a prototype on my laptop of changing VirtualFile.toURL() to return
a VFS based URL. I got it up in working, but ran into a lot of problems when using VFS
based URLs with a URLClassLoader.
The way I had it working was that a URL Handler returned a VirtualFileURLConnection
object. This class delegated to a VirtualFile to openStreams and such.
VirtualFile.toURL() would return a "vfs" base URL. While VirtualFileHandlers
remained untouched and returned their real underlying URL.
For Jars I ran into a lot of Streaming problems where there would be pre-mature
end-of-file errors when loading classes. This was solved by creating
ByteArrayInputStreams around any loading of jar entries. I also found that the URL
Classloader implementation worked differently depending on whether the URL ended in
"/" or not.
What scared me the most about this process was that I had to hack Sun specific by
decompiling it to understand what the problems were as most of the behaviors I had to
debug were not documented.
I'm doing a second iteration of this code right now. One thing I'm going to try
to do is to not return a VirtualFileURLConnection from the VFS protocol Handler, but
instead return VirtualFileHandler.toURL().openConnection(). I think this may solve a lot
of the problems that were encountered initially.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3990063#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...