[jboss-cvs] JBossAS SVN: r78510 - in projects/jboss-cl/trunk/classloading-vfs/src: test/java/org/jboss/test/classloading/vfs/client/support/launcher and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Sep 14 09:28:13 EDT 2008


Author: alesj
Date: 2008-09-14 09:28:12 -0400 (Sun, 14 Sep 2008)
New Revision: 78510

Modified:
   projects/jboss-cl/trunk/classloading-vfs/src/main/java/org/jboss/classloading/spi/vfs/policy/VFSClassLoaderPolicy.java
   projects/jboss-cl/trunk/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/client/support/launcher/ClientLauncher.java
Log:
Refactor Stan's patch a bit.

Modified: projects/jboss-cl/trunk/classloading-vfs/src/main/java/org/jboss/classloading/spi/vfs/policy/VFSClassLoaderPolicy.java
===================================================================
--- projects/jboss-cl/trunk/classloading-vfs/src/main/java/org/jboss/classloading/spi/vfs/policy/VFSClassLoaderPolicy.java	2008-09-14 12:25:23 UTC (rev 78509)
+++ projects/jboss-cl/trunk/classloading-vfs/src/main/java/org/jboss/classloading/spi/vfs/policy/VFSClassLoaderPolicy.java	2008-09-14 13:28:12 UTC (rev 78510)
@@ -48,6 +48,7 @@
 import org.jboss.util.collection.SoftValueHashMap;
 import org.jboss.virtual.VFSUtils;
 import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
 
 /**
  * VFSClassLoaderPolicy.
@@ -63,6 +64,9 @@
    /** Tag for no manifest */
    private static final Manifest NO_MANIFEST = new Manifest();
 
+   /** The leaf virtual file filter */
+   private static final VirtualFileFilter LEAF_FILTER = new LeafVirtualFileFilter();
+
    /** A name for the policy */
    private String name;
    
@@ -552,18 +556,17 @@
             VirtualFile file = root.getChild(path);
             if (file != null)
             {
-               // Must either be a file...
+               // must either be a file ...
                if (file.isLeaf())
                {
                   result = new VirtualFileInfo(file, root);
                   vfsCache.put(path, result);
                   return result;
                }
-               
                // ... or have a child that is a file
-               for (VirtualFile child : file.getChildren())
+               List<VirtualFile> children = file.getChildren(LEAF_FILTER);
+               if (children.isEmpty() == false)
                {
-                  if (!child.isLeaf()) continue;
                   result = new VirtualFileInfo(file, root);
                   vfsCache.put(path, result);
                   return result;
@@ -631,7 +634,7 @@
       }
       try
       {
-         VirtualFile root = findRoot(path);;
+         VirtualFile root = findRoot(path);
          URL codeSourceURL = root.toURL();
          Certificate[] certs = null; // TODO JBMICROCONT-182 determine certificates
          CodeSource cs = new CodeSource(codeSourceURL, certs);
@@ -704,4 +707,22 @@
          return root;
       }
    }
+
+   // accepts only leaves
+   private static class LeafVirtualFileFilter implements VirtualFileFilter
+   {
+      public boolean accepts(VirtualFile file)
+      {
+         try
+         {
+            return file.isLeaf();
+         }
+         catch (IOException e)
+         {
+            // we can return false,
+            // since exception will get ignored any way
+            return false;
+         }
+      }
+   }
 }

Modified: projects/jboss-cl/trunk/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/client/support/launcher/ClientLauncher.java
===================================================================
--- projects/jboss-cl/trunk/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/client/support/launcher/ClientLauncher.java	2008-09-14 12:25:23 UTC (rev 78509)
+++ projects/jboss-cl/trunk/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/client/support/launcher/ClientLauncher.java	2008-09-14 13:28:12 UTC (rev 78510)
@@ -338,7 +338,7 @@
     * @param args
     * @throws Throwable
     */
-   @SuppressWarnings("unchecked")
+   @SuppressWarnings({"unchecked", "deprecation"})
    public static void launch(String clientClass, String clientName, String[] cp, String[] args)
       throws Throwable
    {




More information about the jboss-cvs-commits mailing list