[jboss-cvs] JBossAS SVN: r87574 - projects/jboss-seam-int/trunk/jbossas/src/main/java/org/jboss/seam/integration/jbossas/vfs.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Apr 20 09:20:01 EDT 2009


Author: alesj
Date: 2009-04-20 09:20:01 -0400 (Mon, 20 Apr 2009)
New Revision: 87574

Modified:
   projects/jboss-seam-int/trunk/jbossas/src/main/java/org/jboss/seam/integration/jbossas/vfs/VFSScanner.java
Log:
Handle dirs differently.

Modified: projects/jboss-seam-int/trunk/jbossas/src/main/java/org/jboss/seam/integration/jbossas/vfs/VFSScanner.java
===================================================================
--- projects/jboss-seam-int/trunk/jbossas/src/main/java/org/jboss/seam/integration/jbossas/vfs/VFSScanner.java	2009-04-20 13:13:09 UTC (rev 87573)
+++ projects/jboss-seam-int/trunk/jbossas/src/main/java/org/jboss/seam/integration/jbossas/vfs/VFSScanner.java	2009-04-20 13:20:01 UTC (rev 87574)
@@ -108,20 +108,53 @@
 
    public void scanDirectories(File[] directories)
    {
-      for (File dir : directories)
+      scanDirectories(directories, new File[0]);
+   }
+
+   @Override
+   public void scanDirectories(File[] directories, File[] excludedDirectories)
+   {
+      for (File directory : directories)
       {
-         try
+         handleDirectory(directory, null, excludedDirectories);
+      }
+   }
+
+   /**
+    * Handle directories.
+    *
+    * @param file the file to handle
+    * @param path the current path
+    * @param excludedDirectories the excluded dirs
+    */
+   // TODO - @Pete, this code should be on AbstractScanner
+   private void handleDirectory(File file, String path, File[] excludedDirectories)
+   {
+      for (File excludedDirectory : excludedDirectories)
+      {
+         if (file.equals(excludedDirectory))
          {
-            VirtualFile root = getRoot(dir.toURL(), 0);
-            if (root != null)
-               handleRoot(root);
-            else
-               log.trace("Null root: " + dir);
+            log.trace("Skipping excluded directory: " + file);
+            return;
          }
-         catch (IOException e)
+      }
+
+      log.trace("Handling directory: " + file);
+      for (File child: file.listFiles())
+      {
+         String newPath = path==null ? child.getName() : path + '/' + child.getName();
+         if (child.isDirectory())
          {
-            log.warn("Cannot scan directory " + dir, e);
+            handleDirectory(child, newPath, excludedDirectories);
          }
+         else
+         {
+            if (handle(newPath))
+            {
+               // only try to update the timestamp on this scanner if the file was actually handled
+               touchTimestamp(child);
+            }
+         }
       }
    }
 
@@ -205,7 +238,26 @@
     */
    private void touchTimestamp(VirtualFile file) throws IOException
    {
-      long lastModified = file.getLastModified();
+      touchTimestamp(file.getLastModified());
+   }
+
+   /**
+    * Update timestamp.
+    *
+    * @param file the file to check
+    */
+   private void touchTimestamp(File file)
+   {
+      touchTimestamp(file.lastModified());
+   }
+
+   /**
+    * Update timestamp.
+    *
+    * @param lastModified the timestamp to check
+    */
+   private void touchTimestamp(long lastModified)
+   {
       if (lastModified > timestamp)
       {
          timestamp = lastModified;




More information about the jboss-cvs-commits mailing list