cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup HostConfig.java ContextConfig.java

2004-07-27 Thread remm
remm2004/07/27 03:04:39

  Modified:catalina/src/share/org/apache/catalina/startup
HostConfig.java ContextConfig.java
  Log:
  - Add support for override flag in ContextConfig: none of the default context files 
will be parsed. This flag will only be used if the context
has a config file with override=true in conf/engine/host, because the one in 
/META-INF/context.xml will be parsed later on.
  - Improve support for resource watching.
  - Add the default context files to the monitor list for all contexts.
  
  Revision  ChangesPath
  1.39  +19 -5 
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.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- HostConfig.java   27 Jul 2004 07:17:21 -  1.38
  +++ HostConfig.java   27 Jul 2004 10:04:39 -  1.39
  @@ -600,6 +600,8 @@
   deployedApp.redeployResources.put(docBase.getAbsolutePath(),
   new Long(docBase.lastModified()));
   addWatchedResources(deployedApp, docBase.getAbsolutePath(), 
context);
  +} else {
  +addWatchedResources(deployedApp, null, context);
   }
   } catch (Throwable t) {
   log.error(sm.getString(hostConfig.deployDescriptor.error,
  @@ -767,6 +769,8 @@
   deployedApp.redeployResources.put(docBase.getAbsolutePath(),
   new Long(docBase.lastModified()));
   addWatchedResources(deployedApp, docBase.getAbsolutePath(), 
context);
  +} else {
  +addWatchedResources(deployedApp, null, context);
   }
   } catch (Throwable t) {
   log.error(sm.getString(hostConfig.deployJar.error, file), t);
  @@ -871,13 +875,23 @@
   protected void addWatchedResources(DeployedApplication app, String docBase, 
Context context) {
   // FIXME: Feature idea. Add support for patterns (ex: WEB-INF/*, 
WEB-INF/*.xml), where
   //we would only check if at least one resource is newer than 
app.timestamp
  -File docBaseFile = new File(docBase);
  -if (!docBaseFile.isAbsolute()) {
  -docBaseFile = new File(appBase(), docBase);
  +File docBaseFile = null;
  +if (docBase != null) {
  +docBaseFile = new File(docBase);
  +if (!docBaseFile.isAbsolute()) {
  +docBaseFile = new File(appBase(), docBase);
  +}
   }
   String[] watchedResources = context.findWatchedResources();
   for (int i = 0; i  watchedResources.length; i++) {
  -File resource = new File(docBaseFile, watchedResources[i]);
  +File resource = new File(watchedResources[i]);
  +if (!resource.isAbsolute()) {
  +if (docBase != null) {
  +resource = new File(docBaseFile, watchedResources[i]);
  +} else {
  +continue;
  +}
  +}
   app.reloadResources.put(resource.getAbsolutePath(), 
   new Long(resource.lastModified()));
   }
  
  
  
  1.51  +11 -8 
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/ContextConfig.java
  
  Index: ContextConfig.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- ContextConfig.java26 Jul 2004 15:54:38 -  1.50
  +++ ContextConfig.java27 Jul 2004 10:04:39 -  1.51
  @@ -589,8 +589,10 @@
   protected void contextConfig() {
   
   // FIXME: Externalize default context.xml path the same way as web.xml
  -processContextConfig(new File(getBaseDir(), conf/context.xml));
  -processContextConfig(new File(getConfigBase(), context.xml.default));
  +if (!context.getOverride()) {
  +processContextConfig(new File(getBaseDir(), conf/context.xml));
  +processContextConfig(new File(getConfigBase(), context.xml.default));
  +}
   if (context.getConfigFile() != null)
   processContextConfig(new File(context.getConfigFile()));
   
  @@ -601,8 +603,14 @@
* Process a context.xml.
*/
   protected void processContextConfig(File file) {
  +
   if (log.isDebugEnabled())
   log.debug(Processing context [ + context.getName() + ] configuration 
file  + file);
  +
  +// Add as watched resource so 

cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup HostConfig.java ContextConfig.java ExpandWar.java

2004-07-25 Thread remm
remm2004/07/25 16:35:37

  Modified:catalina/src/share/org/apache/catalina/startup
HostConfig.java ContextConfig.java ExpandWar.java
  Log:
  - Implement a significant amount of reload/redeployment.
  - Since I'm a happy (?) user of MickeyMouse(TM) OS (aka Windows), I can't really 
test stuff without the anti-locking code
which I haven't implemented yet. I'll do that tomorrow (this seems simple).
  - I used some ideas from Peter, and managed to notice code I could remove. Thanks.
  - Please don't file bugs on this until I've at least tested a bit :)
  - I need to add one extra method and refactor a bit to allow usage through the 
manager webapp (the manager webapp
will want synced operation, I think, so the background thread won't do it in that 
case - although it would do the job
eventually).
  - I'll also add the new extra configuration items tomorrow, such as the 
watchedfile feature (that's simple).
  
  Revision  ChangesPath
  1.35  +230 -159  
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.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- HostConfig.java   23 Jul 2004 22:57:34 -  1.34
  +++ HostConfig.java   25 Jul 2004 23:35:37 -  1.35
  @@ -23,7 +23,6 @@
   import java.io.FileOutputStream;
   import java.io.IOException;
   import java.io.InputStream;
  -import java.net.URL;
   import java.util.ArrayList;
   import java.util.HashMap;
   import java.util.jar.JarEntry;
  @@ -36,6 +35,7 @@
   import org.apache.catalina.Lifecycle;
   import org.apache.catalina.LifecycleEvent;
   import org.apache.catalina.LifecycleListener;
  +import org.apache.catalina.core.ContainerBase;
   import org.apache.catalina.core.StandardHost;
   import org.apache.catalina.util.StringManager;
   import org.apache.tomcat.util.digester.Digester;
  @@ -422,14 +422,13 @@
   
   File appBase = appBase();
   File configBase = configBase();
  -do {
  -// Deploy XML descriptors from configBase
  -deployDescriptors(configBase, configBase.list());
  -// Deploy expanded folders
  -deployDirectories(appBase, appBase.list());
  -// Deploy WARs, and loop if additional descriptors are found
  -} while (deployWARs(appBase, appBase.list()));
  -
  +// Deploy XML descriptors from configBase
  +deployDescriptors(configBase, configBase.list());
  +// Deploy WARs, and loop if additional descriptors are found
  +deployWARs(appBase, appBase.list());
  +// Deploy expanded folders
  +deployDirectories(appBase, appBase.list());
  +
   }
   
   
  @@ -460,6 +459,8 @@
   if (deployed.containsKey(contextPath))
   continue;
   
  +DeployedApplication deployedApp = new 
DeployedApplication(contextPath);
  +
   // Assume this is a configuration descriptor and deploy it
   log.debug(sm.getString(hostConfig.deployDescriptor, files[i]));
   try {
  @@ -475,15 +476,45 @@
   }
   newContext.setConfigFile(contextXml.getAbsolutePath());
   newContext.setPath(contextPath);
  +// Add the context XML to the list of watched files
  +deployedApp.reloadResources.put
  +(contextXml.getAbsolutePath(), new 
Long(contextXml.lastModified()));
  +// Add the associated docBase to the redeployed list if it's a 
WAR
  +boolean isWar = false;
  +if (newContext.getDocBase() != null) {
  +File docBase = new File(newContext.getDocBase());
  +if (!docBase.isAbsolute()) {
  +docBase = new File(new File(host.getAppBase()), 
  +newContext.getDocBase());
  +}
  +deployedApp.redeployResources.put(docBase.getAbsolutePath(),
  +new Long(docBase.lastModified()));
  +if 
(docBase.getAbsolutePath().toLowerCase().endsWith(.war)) {
  +isWar = true;
  +}
  +}
   host.addChild(newContext);
  +// Add the eventual unpacked WAR and all the resources which 
will be
  +// watched inside it
  +if (isWar  unpackWARs  (newContext.getDocBase() != null)) {
  +File docBase = new File(newContext.getDocBase());
  +