cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r518069 - in /cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/tools/rcl/wrapper/servlet: CocoonReloadingListener.java ReloadingSpringFilter.java
Date Wed, 14 Mar 2007 08:36:16 GMT
Author: reinhard
Date: Wed Mar 14 01:36:15 2007
New Revision: 518069

URL: http://svn.apache.org/viewvc?view=rev&rev=518069
Log:
- improve logging
- remove debugging code

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

Modified: cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/tools/rcl/wrapper/servlet/CocoonReloadingListener.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/tools/rcl/wrapper/servlet/CocoonReloadingListener.java?view=diff&rev=518069&r1=518068&r2=518069
==============================================================================
--- cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/tools/rcl/wrapper/servlet/CocoonReloadingListener.java
(original)
+++ cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/tools/rcl/wrapper/servlet/CocoonReloadingListener.java
Wed Mar 14 01:36:15 2007
@@ -34,33 +34,32 @@
 
     public void onFileChange(File file) {
         super.onFileChange(file);
-        changeDetected(file);
+        changeDetected(file, "update");
     }
     
     public void onFileDelete(File file) {
         super.onFileDelete(file);
-        changeDetected(file);
+        changeDetected(file, "delete");
     }
     
     public void onFileCreate(File file) {
         super.onFileCreate(file);
-        changeDetected(file);
+        changeDetected(file, "create");
     }   
     
-    protected void changeDetected(File changedFile) {
+    protected void changeDetected(File changedFile, String operation) {
         String changedFileParentPath = changedFile.getParent().replace('\\', '/');
         String changedFilePath = changedFile.getAbsolutePath().replace('\\', '/');      
 
 
-        if(changedFileParentPath.endsWith("META-INF/cocoon/spring") ||        // global Spring
beans configurations
-                changedFileParentPath.endsWith("config/avalon") ||            // global Avalon
components
-                changedFilePath.endsWith(".xmap") ||                          // any file
that ends with xmap (sitemaps)
-                changedFilePath.endsWith(".xmap.xml") ||                      // any sitemap
that ends with xmap.xml (sitemaps)
-                changedFileParentPath.endsWith("config/spring")) {            // local Spring
bean configurations
-            log.info("Configuration file change detected: " + changedFile);
-            System.out.println("Configuration file change detected: " + changedFile);
+        if(changedFileParentPath.endsWith("META-INF/cocoon/spring") ||              // global
Spring beans configurations
+                changedFileParentPath.endsWith("config/avalon") ||                  // global
Avalon components
+                changedFilePath.endsWith(".xmap") ||                                // any
file that ends with xmap (sitemaps)
+                changedFilePath.endsWith(".xmap.xml") ||                            // any
sitemap that ends with xmap.xml (sitemaps)
+                changedFileParentPath.endsWith("config/spring")) {                  // local
Spring bean configurations
+            log.debug("Configuration file change detected [" + operation + "]: " + changedFile);
             reload = true;
         } else {
-            log.debug("File change detected: " + changedFile);                // any other
file change
+            log.debug("File change detected [" + operation + "]: " + changedFile);  // any
other file change
             reload = true;
         }
     }
@@ -73,4 +72,4 @@
         return reload;
     }
 
-}
+}
\ No newline at end of file

Modified: cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/tools/rcl/wrapper/servlet/ReloadingSpringFilter.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/tools/rcl/wrapper/servlet/ReloadingSpringFilter.java?view=diff&rev=518069&r1=518068&r2=518069
==============================================================================
--- cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/tools/rcl/wrapper/servlet/ReloadingSpringFilter.java
(original)
+++ cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/tools/rcl/wrapper/servlet/ReloadingSpringFilter.java
Wed Mar 14 01:36:15 2007
@@ -28,10 +28,8 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.springframework.context.ApplicationContext;
-import org.springframework.core.io.DefaultResourceLoader;
 import org.springframework.web.context.ContextLoader;
 import org.springframework.web.context.WebApplicationContext;
-import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.support.ServletContextFactoryBean;
 import org.springframework.web.context.support.WebApplicationContextUtils;
 import org.springframework.web.context.support.XmlWebApplicationContext;
@@ -52,7 +50,7 @@
             ServletException {
         
         if(CocoonReloadingListener.isReload()) {
-            synchronized (this) {
+            synchronized (this) {            
                 // load the spring context loader from the reloading classloader
                 ClassLoader cl = ReloadingClassloaderManager.getClassLoader(config.getServletContext());
                 ContextLoader springContextLoader = null;
@@ -62,18 +60,12 @@
                 } catch (Exception e) {
                     throw new ServletException("Cannot load class " + ContextLoader.class.getName(),
e);
                 }
-                
-                // debugging code
-                try {
+
+                // close old Spring application context
+                if(log.isDebugEnabled()) {                
                     ApplicationContext oldAc = WebApplicationContextUtils.getRequiredWebApplicationContext(this.config.getServletContext());
-                    this.log.debug("Old application context: " + oldAc);
-                    Object o = oldAc.getBean("global-bean");
-                    this.log.debug("o[old]: " + o.toString());             
-                } catch(Exception e) {
+                    this.log.debug("Removing old application context: " + oldAc);      
                 }
-                // debugging code end
-                
-                // close old Spring application context
                 springContextLoader.closeWebApplicationContext(this.config.getServletContext());
                 this.config.getServletContext().removeAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
 
@@ -81,22 +73,9 @@
                 ServletContextFactoryBean b = new ServletContextFactoryBean();
                 b.setServletContext(this.config.getServletContext());
                 XmlWebApplicationContext xac = (XmlWebApplicationContext) springContextLoader.initWebApplicationContext(this.config.getServletContext());
-                
-                // debugging code
-                try {
-                    DefaultResourceLoader drl = (DefaultResourceLoader) xac;
-                    drl.setClassLoader(cl);
-                    xac.refresh();
-                    Object o1 = xac.getBean("global-bean");
-                    this.log.debug("o[new]: " + o1.toString());
-                } catch(Exception e) {
-                }
-                // debugging code end
-                
                 if(log.isDebugEnabled()) {
-                    log.debug("Reloaded Spring application context: " + xac);
+                    log.debug("Reloading Spring application context: " + xac);
                 }
-                
             }
         }
         // continue processing the request
@@ -108,7 +87,6 @@
 
     public void init(FilterConfig filterConfig) throws ServletException {
         this.config = filterConfig;
-        
     }
  
-}
+}
\ No newline at end of file



Mime
View raw message