[jboss-cvs] JBossAS SVN: r83841 - projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/registry.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Feb 4 03:35:55 EST 2009


Author: alesj
Date: 2009-02-04 03:35:54 -0500 (Wed, 04 Feb 2009)
New Revision: 83841

Modified:
   projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/registry/DefaultVFSRegistry.java
Log:
Refactor code.

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/registry/DefaultVFSRegistry.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/registry/DefaultVFSRegistry.java	2009-02-04 06:59:29 UTC (rev 83840)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/registry/DefaultVFSRegistry.java	2009-02-04 08:35:54 UTC (rev 83841)
@@ -77,32 +77,38 @@
             String path = ti.getPath();
             if (relativePath.startsWith(path) && ti.getHandler() != null)
             {
-               VirtualFileHandler handler = ti.getHandler();
                String subpath = relativePath.substring(path.length());
-               VirtualFileHandler child = handler.getChild(subpath);
-               if (child == null)
-               {
-                  List<VirtualFileHandler> children = handler.getChildren(true);
-                  throw new IOException("Child not found " + subpath + " for " + handler + ", available children: " + children);
-               }
-
+               VirtualFileHandler child = findHandler(ti.getHandler(), subpath);
                return child.getVirtualFile();
             }
          }
 
          VirtualFileHandler root = context.getRoot();
-         VirtualFileHandler child = root.getChild(relativePath);
-         if (child == null)
-         {
-            List<VirtualFileHandler> children = root.getChildren(true);
-            throw new IOException("Child not found " + relativePath + " for " + root + ", available children: " + children);
-         }
-
+         VirtualFileHandler child = findHandler(root, relativePath);
          return child.getVirtualFile();
       }
       return null;
    }
 
+   /**
+    * Find the handler.
+    *
+    * @param root the root
+    * @param path the path
+    * @return child handler
+    * @throws IOException for any error
+    */
+   protected VirtualFileHandler findHandler(VirtualFileHandler root, String path) throws IOException
+   {
+      VirtualFileHandler child = root.getChild(path);
+      if (child == null)
+      {
+         List<VirtualFileHandler> children = root.getChildren(true);
+         throw new IOException("Child not found " + path + " for " + root + ", available children: " + children);
+      }
+      return child;
+   }
+
    public VirtualFile getFile(URL url) throws IOException
    {
       if (url == null)




More information about the jboss-cvs-commits mailing list