[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: JarEntry as VFS root does not return empty vfspath
mstruk
do-not-reply at jboss.com
Thu Mar 20 20:03:47 EDT 2008
Ok, I'm implementing the fix to work with root-name-not-an-empty-string contract.
Root node test:
| isContextRoot = parent == null
|
does not work for situations where context root is not the jar itself but a path within it (jar://some/path.jar!/child).
In the absence of isRoot field on AbstractVirtualFileHandler one approach is along the line:
| public boolean isContextRoot() {
|
| try
| {
| VirtualFileHandler ctxRoot = getVFSContext().getRoot();
| return this == ctxRoot;
| }
| catch (IOException e)
| {
| throw new RuntimeException("Failed to get context root: ", e);
| }
|
| }
|
but it blows up on getVFSContext() if handler has been closed - it goes into infinite recursion (because I call isContextRoot() inside initPath() which is called from getPathName() which is called from toString() which is called from Exception generating constructor within getVFSContext()... a mess :)
I think it's overkill to blow on getVFSContext() which is just a field retrieval - no logic invoked. We should let the code retrieve the context and let the context blow up later if some operation is invoked on it.
Lazy init of contextPath is also a mine that makes things blow up when you poke around and play with code. Things would be much more predictable if we just set it through constructor and make it non transient.
To stick to the issue - I think it would be best to introduce non-transient field boolean isContextRoot to AbstractVirtualFileHandler and init it through constructor.
BTW: Is there a wiki page I can use for a little VFS guide I'm putting together? Where others in-the-know can point out inaccuracies I commit :)
- marko
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4138206#4138206
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4138206
More information about the jboss-dev-forums
mailing list