cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r510483 - in /cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/servlet: CocoonReloadingListener.java ReloadingClassloaderManager.java ReloadingSpringFilter.java
Date Thu, 22 Feb 2007 12:40:00 GMT
Author: reinhard
Date: Thu Feb 22 04:39:59 2007
New Revision: 510483

URL: http://svn.apache.org/viewvc?view=rev&rev=510483
Log:
- be more specific with Spring context reloads. Only perform a reload if
  there is a change in META-INF/cocoon/spring, config/spring or a file that
  ends with .xmap or .xmap.xml.
- to much cleanup in the CloassLoaderManager
- comment unused code in the CocoonReloadingListener

Modified:
    cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/servlet/CocoonReloadingListener.java
    cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/servlet/ReloadingClassloaderManager.java
    cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/servlet/ReloadingSpringFilter.java

Modified: cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/servlet/CocoonReloadingListener.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/servlet/CocoonReloadingListener.java?view=diff&rev=510483&r1=510482&r2=510483
==============================================================================
--- cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/servlet/CocoonReloadingListener.java
(original)
+++ cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/servlet/CocoonReloadingListener.java
Thu Feb 22 04:39:59 2007
@@ -17,6 +17,9 @@
 package org.apache.cocoon.servlet;
 
 import java.io.File;
+//import java.util.ArrayList;
+//import java.util.Iterator;
+//import java.util.List;
 
 import org.apache.commons.jci.listeners.ReloadingListener;
 
@@ -30,13 +33,27 @@
     }
 
     public void onChangeFile(File changedFile) {
+        String changedFilePath = changedFile.getAbsolutePath().replace('\\', '/');
+        String changedFileParent = changedFile.getParent().replace('\\', '/');
+        
+        
         System.out.println("A file changed: " + changedFile.getAbsolutePath());
+        System.out.println("Parent: " + changedFile.getParent());
         super.onChangeFile(changedFile);
-//        notifySubscribers();
+
         
         // TODO be more specific when to reload. Not every change needs a reload of the Spring
         // application context
-        reload = true;
+        if(changedFileParent.endsWith("META-INF/cocoon/spring") ||
+                changedFilePath.endsWith(".xmap") ||
+                changedFilePath.endsWith(".xmap.xml") ||
+                changedFileParent.endsWith("config/spring")) {
+            System.out.println("File change detected: " + changedFile);       
+            reload = true;            
+        }
+        
+//        notifySubscribers();        
+
     }
 
     public void onChangeDirectory(File changedDirectory) {
@@ -51,7 +68,7 @@
         }
         return reload;
     }
-    
+//    
 //    private void notifySubscribers() {
 //        for(Iterator nIt = subscribers.iterator(); nIt.hasNext(); ) {
 //            ((ReloadingNotificationSubscriber) nIt.next()).handleNotification();
@@ -59,7 +76,6 @@
 //    }
 //    
 //    public static void subscribe(ReloadingNotificationSubscriber subscriber) {
-//        System.out.println("----------> Subscription by: " + subscriber);
 //        subscribers.add(subscriber);
 //    }
     

Modified: cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/servlet/ReloadingClassloaderManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/servlet/ReloadingClassloaderManager.java?view=diff&rev=510483&r1=510482&r2=510483
==============================================================================
--- cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/servlet/ReloadingClassloaderManager.java
(original)
+++ cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/servlet/ReloadingClassloaderManager.java
Thu Feb 22 04:39:59 2007
@@ -56,6 +56,7 @@
                 fam.addListener(rl);
             }
             fam.start();
+            ReloadingClassloaderManager.reloadingClassloader = classloader; 
         }   
         return ReloadingClassloaderManager.reloadingClassloader;
     }    

Modified: cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/servlet/ReloadingSpringFilter.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/servlet/ReloadingSpringFilter.java?view=diff&rev=510483&r1=510482&r2=510483
==============================================================================
--- cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/servlet/ReloadingSpringFilter.java
(original)
+++ cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/servlet/ReloadingSpringFilter.java
Thu Feb 22 04:39:59 2007
@@ -45,19 +45,18 @@
             synchronized (this) {
                 // load the spring context loader from the reloading classloader
                 ClassLoader cl = ReloadingClassloaderManager.getClassLoader(config.getServletContext());
-                String contextLoaderClassName = ContextLoader.class.getName();
                 ContextLoader springContextLoader = null;
                 try {
-                    Class contextLoaderClass = cl.loadClass(contextLoaderClassName);
+                    Class contextLoaderClass = cl.loadClass(ContextLoader.class.getName());
                     springContextLoader = (ContextLoader) contextLoaderClass.newInstance();
                 } catch (Exception e) {
-                    throw new ServletException("Cannot load class " + contextLoaderClassName,
e);
+                    throw new ServletException("Cannot load class " + ContextLoader.class.getName(),
e);
                 }
                 
                 // close old Spring application context
                 springContextLoader.closeWebApplicationContext(this.config.getServletContext());
                 this.config.getServletContext().removeAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
-                
+
                 // create the new Spring application context
                 springContextLoader.initWebApplicationContext(this.config.getServletContext());
             }



Mime
View raw message