remm        01/12/03 14:19:43

  Modified:    catalina/src/share/org/apache/catalina/startup
                        HostConfig.java
  Log:
  - Make the deployment order predictable.
    - XML context descriptors are deployed first.
    - WARs are deployed next.
    - Extracted webapps are deployed last.
  
  Revision  Changes    Path
  1.15      +89 -35    
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/HostConfig.java
  
  Index: HostConfig.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/HostConfig.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- HostConfig.java   2001/10/27 19:05:17     1.14
  +++ HostConfig.java   2001/12/03 22:19:42     1.15
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/HostConfig.java,v
 1.14 2001/10/27 19:05:17 craigmcc Exp $
  - * $Revision: 1.14 $
  - * $Date: 2001/10/27 19:05:17 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/HostConfig.java,v
 1.15 2001/12/03 22:19:42 remm Exp $
  + * $Revision: 1.15 $
  + * $Date: 2001/12/03 22:19:42 $
    *
    * ====================================================================
    *
  @@ -101,7 +101,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.14 $ $Date: 2001/10/27 19:05:17 $
  + * @version $Revision: 1.15 $ $Date: 2001/12/03 22:19:42 $
    */
   
   public class HostConfig
  @@ -315,6 +315,18 @@
               return;
           String files[] = appBase.list();
   
  +        deployDescriptors(appBase, files);
  +        deployWARs(appBase, files);
  +        deployDirectories(appBase, files);
  +
  +    }
  +
  +
  +    /**
  +     * Deploy XML context descriptors.
  +     */
  +    protected void deployDescriptors(File appBase, String[] files) {
  +
           for (int i = 0; i < files.length; i++) {
   
               if (files[i].equalsIgnoreCase("META-INF"))
  @@ -324,36 +336,7 @@
               if (deployed.contains(files[i]))
                   continue;
               File dir = new File(appBase, files[i]);
  -            if (dir.isDirectory()) {
  -
  -                deployed.add(files[i]);
  -
  -                // Make sure there is an application configuration directory
  -                /* Don't be more fussy than the Deployer implementation is
  -                File webInf = new File(dir, "/WEB-INF");
  -                if (!webInf.exists() || !webInf.isDirectory() ||
  -                    !webInf.canRead())
  -                    continue;
  -                */
  -
  -                // Calculate the context path and make sure it is unique
  -                String contextPath = "/" + files[i];
  -                if (files[i].equals("ROOT"))
  -                    contextPath = "";
  -                if (host.findChild(contextPath) != null)
  -                    continue;
  -
  -                // Deploy the application in this directory
  -                log(sm.getString("hostConfig.deployDir", files[i]));
  -                try {
  -                    URL url = new URL("file", null, dir.getCanonicalPath());
  -                    ((Deployer) host).install(contextPath, url);
  -                } catch (Throwable t) {
  -                    log(sm.getString("hostConfig.deployDir.error", files[i]),
  -                        t);
  -                }
  -
  -            } else if (files[i].toLowerCase().endsWith(".xml")) {
  +            if (files[i].toLowerCase().endsWith(".xml")) {
   
                   deployed.add(files[i]);
   
  @@ -367,9 +350,30 @@
                       log(sm.getString("hostConfig.deployDescriptor.error",
                                        files[i]), t);
                   }
  +
  +            }
  +
  +        }
  +
  +    }
   
  -            } else if (files[i].toLowerCase().endsWith(".war")) {
   
  +    /**
  +     * Deploy WAR files.
  +     */
  +    protected void deployWARs(File appBase, String[] files) {
  +
  +        for (int i = 0; i < files.length; i++) {
  +
  +            if (files[i].equalsIgnoreCase("META-INF"))
  +                continue;
  +            if (files[i].equalsIgnoreCase("WEB-INF"))
  +                continue;
  +            if (deployed.contains(files[i]))
  +                continue;
  +            File dir = new File(appBase, files[i]);
  +            if (files[i].toLowerCase().endsWith(".war")) {
  +
                   deployed.add(files[i]);
   
                   // Calculate the context path and make sure it is unique
  @@ -390,6 +394,56 @@
                       ((Deployer) host).install(contextPath, url);
                   } catch (Throwable t) {
                       log(sm.getString("hostConfig.deployJar.error", files[i]),
  +                        t);
  +                }
  +
  +            }
  +
  +        }
  +
  +    }
  +
  +
  +    /**
  +     * Deploy directories.
  +     */
  +    protected void deployDirectories(File appBase, String[] files) {
  +
  +        for (int i = 0; i < files.length; i++) {
  +
  +            if (files[i].equalsIgnoreCase("META-INF"))
  +                continue;
  +            if (files[i].equalsIgnoreCase("WEB-INF"))
  +                continue;
  +            if (deployed.contains(files[i]))
  +                continue;
  +            File dir = new File(appBase, files[i]);
  +            if (dir.isDirectory()) {
  +
  +                deployed.add(files[i]);
  +
  +                // Make sure there is an application configuration directory
  +                /* Don't be more fussy than the Deployer implementation is
  +                File webInf = new File(dir, "/WEB-INF");
  +                if (!webInf.exists() || !webInf.isDirectory() ||
  +                    !webInf.canRead())
  +                    continue;
  +                */
  +
  +                // Calculate the context path and make sure it is unique
  +                String contextPath = "/" + files[i];
  +                if (files[i].equals("ROOT"))
  +                    contextPath = "";
  +                if (host.findChild(contextPath) != null)
  +                    continue;
  +
  +                // Deploy the application in this directory
  +                log(sm.getString("hostConfig.deployDir", files[i]));
  +                try {
  +                    URL url = new URL("file", null, dir.getCanonicalPath());
  +                    ((Deployer) host).install(contextPath, url);
  +                } catch (Throwable t) {
  +                    log(sm.getString("hostConfig.deployDir.error", files[i]),
                           t);
                   }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to