remm        2003/06/10 13:01:31

  Modified:    catalina/src/share/org/apache/catalina/startup
                        HostConfig.java
  Log:
  - Small deployer refactorings, as discussed previsouly.
  - Track WARs for changes when unpacking WARs. If WAR gets updated,
    redeploy webapp.
  
  Revision  Changes    Path
  1.11      +53 -10    
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/HostConfig.java
  
  Index: HostConfig.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/HostConfig.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- HostConfig.java   22 May 2003 23:05:36 -0000      1.10
  +++ HostConfig.java   10 Jun 2003 20:01:31 -0000      1.11
  @@ -188,6 +188,12 @@
   
   
       /**
  +     * Last modified dates of the source WAR files, keyed by WAR name.
  +     */
  +    private HashMap warLastModified = new HashMap();
  +
  +
  +    /**
        * Attribute value used to turn on/off XML validation
        */
       private boolean xmlValidation = false;
  @@ -689,16 +695,50 @@
   
           }
   
  +        // Check for WAR modification
  +        if (isUnpackWARs()) {
  +            File appBase = appBase();
  +            if (!appBase.exists() || !appBase.isDirectory())
  +                return;
  +            String files[] = appBase.list();
  +
  +            for (int i = 0; i < files.length; i++) {
  +                if (files[i].endsWith(".war")) {
  +                    File dir = new File(appBase, files[i]);
  +                    Long lastModified = (Long) warLastModified.get(files[i]);
  +                    if (lastModified == null) {
  +                        warLastModified.put
  +                            (files[i], new Long(dir.lastModified()));
  +                    } else if (dir.lastModified() > lastModified.longValue()) {
  +                        // The WAR has been modified: redeploy
  +                        String expandedDir = files[i];
  +                        int period = expandedDir.lastIndexOf(".");
  +                        if (period >= 0)
  +                            expandedDir = expandedDir.substring(0, period);
  +                        String contextPath = "/" + expandedDir;
  +                        if (contextPath.equals("/ROOT"))
  +                            contextPath = "";
  +                        try {
  +                            ((Deployer) host).remove(contextPath, true);
  +                            deployed.remove(files[i]);
  +                        } catch (Throwable t) {
  +                            log.error(sm.getString("hostConfig.undeployJar.error",
  +                                                   files[i]), t);
  +                        }
  +                        webXmlLastModified.remove(contextPath);
  +                        warLastModified.put
  +                            (files[i], new Long(dir.lastModified()));
  +                        deployApps();
  +                    }
  +                }
  +            }
  +        }
  +
       }
   
   
       protected boolean restartContext(Context context) {
           boolean result = true;
  -        if( context.getReloadable() == false ) {
  -            log.info("restartContext(" + context.getName() + "): not reloadable");
  -            return false;
  -        }
  -
           log.info("restartContext(" + context.getName() + ")");
   
           /*
  @@ -853,13 +893,16 @@
               }
           }
   
  +        webXmlLastModified.clear();
  +        deployed.clear();
  +
       }
   
   
       /**
        * Deploy webapps.
        */
  -    public void check() {
  +    protected void check() {
   
           if (host.getAutoDeploy()) {
               // Deploy apps if the Host allows auto deploying
  
  
  

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

Reply via email to