remm        2003/06/10 13:03:42

  Modified:    catalina/src/share/org/apache/catalina/core
                        StandardHostDeployer.java
  Log:
  - Small deployer refactorings, as discussed previsouly.
  - Don't remove WAR if newer than unpacked directory.
  - Generalize WAR unpacking, based on the unpackWAR flag.
  
  Revision  Changes    Path
  1.9       +25 -2     
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardHostDeployer.java
  
  Index: StandardHostDeployer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardHostDeployer.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- StandardHostDeployer.java 25 Apr 2003 21:16:22 -0000      1.8
  +++ StandardHostDeployer.java 10 Jun 2003 20:03:42 -0000      1.9
  @@ -376,8 +376,14 @@
                                 contextPath, war.toString()));
           String url = war.toString();
           String docBase = null;
  +        boolean isWAR = false;
           if (url.startsWith("jar:")) {
               url = url.substring(4, url.length() - 2);
  +            if (!url.toLowerCase().endsWith(".war")) {
  +                throw new IllegalArgumentException
  +                    (sm.getString("standardHost.warURL", url));
  +            }
  +            isWAR = true;
           }
           if (url.startsWith("file://"))
               docBase = url.substring(7);
  @@ -387,6 +393,11 @@
               throw new IllegalArgumentException
                   (sm.getString("standardHost.warURL", url));
   
  +        // Expand war file if host wants wars unpacked
  +        if (isWAR && host.isUnpackWARs()) {
  +            docBase = ExpandWar.expand(host, war, contextPath);
  +        }
  +
           // Install the new web application
           try {
               Class clazz = Class.forName(host.getContextClass());
  @@ -457,12 +468,14 @@
   
           // Calculate the document base for the new web application (if needed)
           String docBase = null; // Optional override for value in config file
  +        boolean isWAR = false;
           if (war != null) {
               String url = war.toString();
               log.info(sm.getString("standardHost.installingWAR", url));
               // Calculate the WAR file absolute pathname
               if (url.startsWith("jar:")) {
                   url = url.substring(4, url.length() - 2);
  +                isWAR = true;
               }
               if (url.startsWith("file://"))
                   docBase = url.substring(7);
  @@ -474,6 +487,11 @@
   
           }
   
  +        // Expand war file if host wants wars unpacked
  +        if (isWAR && host.isUnpackWARs()) {
  +            docBase = ExpandWar.expand(host, war);
  +        }
  +
           // Install the new web application
           this.context = null;
           this.overrideDocBase = docBase;
  @@ -653,13 +671,18 @@
                       if (contextPath.length() == 0 && filename.equals("ROOT") ||
                           filename.equals(contextPath.substring(1))) {
                           if (!isWAR) {
  +                            long contextLastModified = 
  +                                contextFile.lastModified();
                               if (contextFile.isDirectory()) {
                                   deleteDir(contextFile);
                               }
                               if (host.isUnpackWARs()) {
                                   File contextWAR = new File(context.getDocBase() + 
".war");
                                   if (contextWAR.exists()) {
  -                                    contextWAR.delete();
  +                                    if (contextLastModified 
  +                                        > contextWAR.lastModified()) {
  +                                        contextWAR.delete();
  +                                    }
                                   }
                               }
                           } else {
  
  
  

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

Reply via email to