Patches item #543611, was opened at 2002-04-14 00:23
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=376687&aid=543611&group_id=22866

Category: JBossServer
Group: v3.0 Rabbit Hole (unstable)
Status: Open
Resolution: None
Priority: 5
Submitted By: Larry Sanderson (lsanders)
Assigned to: Nobody/Anonymous (nobody)
Summary: Scan a deployable directory

Initial Comment:
Currently, if you specify a directory for the 
URLScanner, it will always deploy the contents of that 
directory.  It may, however, be desirable to deploy 
the directory itself if it happens to be an exploded 
archive.

This patch adds some logic to the scanner to determine 
if a directory is itself deployable.  If it is, then 
the directory is deployed, otherwise its contents are 
deployed as usual.

-Larry

=======================================================
============
RCS file: /cvsroot/jboss/jboss-
system/src/main/org/jboss/deployment/scanner/URLDeploym
entScanner.java,v
retrieving revision 1.13
diff -u -r1.13 URLDeploymentScanner.java
--- 
system/src/main/org/jboss/deployment/scanner/URLDeploym
entScanner.java 14 Apr 2002 01:19:54 -0000      1.13
+++ 
system/src/main/org/jboss/deployment/scanner/URLDeploym
entScanner.java 14 Apr 2002 07:17:45 -0000
@@ -33,6 +33,7 @@
 import org.jboss.util.NullArgumentException;
 
 import org.jboss.deployment.DeploymentSorter;
+import java.util.Collection;
 
 /**
  * A URL-based deployment scanner.  Supports local 
directory 
@@ -404,15 +405,28 @@
          URL[] urls = (URL[]) urlList.toArray( new URL
[] {} );
          for( int i = 0; i < urls.length; i++ )
          {
-            if (!isDeployed(urls[i])) {
-               if (urls[i].getProtocol().equals
("file")) {
-                  // it is a file url which gets 
special handling
-                  scanDirectory(urls[i]);
-               }
-               else {
-                  // just deploy, not a file url and 
not yet deployed
-                  deploy(new DeployedURL(urls[i]));
+            URL url = urls[i];
+            if (!isDeployed(url)) {
+               if (url.getProtocol().equals("file")) {
+                  // if this is a non-deployable 
directory, scan it
+                  File file = new File(url.getFile());
+                  
+                  // make sure it exists
+                  if (!file.exists()) {
+                     if (trace) {
+                        log.trace("Skipping non-
existant file: " + file);
+                     }
+                     continue;
+                  }
+
+                  // if it is a non-deployable 
directory, scan it
+                  if (file.isDirectory() && !
isDeployable(file.getName())) {
+                     scanDirectory(file);
+                     continue;
+                  }
                }
+               // just deploy, not yet deployed
+               deploy(new DeployedURL(url));
             }
          }
       }
@@ -460,40 +474,44 @@
          deploy(du);
       }
    }
+   
+   /**
+    * Determine if the specified URL is deployable.  
This just checks the 
+    * extension for a known archive type.  Perhaps we 
shouls call all
+    * installed subdeployers' accepts methods??  
+    *
+    * Not much bad will happen if this method is 
inaccurate.  If it returns
+    * true when the dir is not actually deployable, 
then it will be picked
+    * up by JARDeployer, and the sub directories will 
be correctly deployed.
+    * The draw back is that the deployed entities 
will not be scanned for 
+    * future modification.
+    *
+    * If false is returned when it should be 
deployed, then we have the 
+    * same behaviour as the original implementation - 
the first level of the
+    * directory will be scanned for deployable units.
+    */
+   private boolean isDeployable(String name) {
+      return name.endsWith(".jar")
+          || name.endsWith(".sar")
+          || name.endsWith(".ear")
+          || name.endsWith(".rar")
+          || name.endsWith(".zip")
+          || name.endsWith(".wsr")
+          || name.endsWith(".war");
+   }
 
    /**
     * @todo Add configurable filter support.
     * @todo Add configurable nesting which recurses 
back to scanDirectory.
     */
-   protected void scanDirectory(URL url) throws 
Exception
+   protected void scanDirectory(File file) throws 
Exception
    {
       boolean trace = log.isTraceEnabled();
 
       if (trace) {
-         log.trace("Scanning directory: " + url);
-      }
-
-      if (isDeployed(url)) {
-         // short-circuit on deployed urls, for 
nesting support
-         return;
-      }
-
-      File file = new File(url.getFile());
-
-      // make sure it exists
-      if (!file.exists()) {
-         if (trace) {
-            log.trace("Skipping non-existant file: " 
+ file);
-         }
-         return;
+         log.trace("Scanning directory: " + file);
       }
 
-      // if it is not a directory, and it is not 
deployed then add it
-      if (!file.isDirectory()) {
-         // just a plain file which isn't deployed
-         deploy(new DeployedURL(url));
-         return;
-      }
       // else it is a directory, scan it
         
       File[] files = file.listFiles();
@@ -511,7 +529,7 @@
          }
             
          // It is a new file
-         url = files[i].toURL();
+         URL url = files[i].toURL();
          if (!isDeployed(url)) {
             list.add(url);
          }
@@ -526,7 +544,7 @@
       Iterator iter = list.iterator();
       while (iter.hasNext()) 
       {
-         url = (URL)iter.next();
+         URL url = (URL)iter.next();
          deploy(new DeployedURL(url));
       }
    }


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=376687&aid=543611&group_id=22866

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to