cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r635835 - in /cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/tools/rcl/wrapper/servlet: CocoonReloadingListener.java ReloadingServlet.java ReloadingServletFilter.java
Date Tue, 11 Mar 2008 07:49:13 GMT
Author: reinhard
Date: Tue Mar 11 00:49:12 2008
New Revision: 635835

URL: http://svn.apache.org/viewvc?rev=635835&view=rev
Log:
the previous solution only wrote to the console after the first 'update' event had arrived.
In practice this will mostly be good enough but if your first change is a 'create' event,
it doesn't appear. 

this fix turns on console output when the first servlet or filter is called.

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/ReloadingServlet.java
    cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/tools/rcl/wrapper/servlet/ReloadingServletFilter.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?rev=635835&r1=635834&r2=635835&view=diff
==============================================================================
--- 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
Tue Mar 11 00:49:12 2008
@@ -28,7 +28,7 @@
 
     private static boolean reload = false;
 
-    private boolean consoleOutput = false;
+    private static boolean consoleOutput = false;
 
     public CocoonReloadingListener() {
         super();
@@ -37,14 +37,12 @@
     public void onFileChange(File file) {
         super.onFileChange(file);
         // after the first change/deletion of a file is detected, log to the console
-        this.consoleOutput = true;
         changeDetected(file, "update");
     }
 
     public void onFileDelete(File file) {
         super.onFileDelete(file);
         // after the first change/deletion of a file is detected, log to the console
-        this.consoleOutput = true;
         changeDetected(file, "delete");
     }
 
@@ -65,13 +63,17 @@
                 changedFileParentPath.endsWith("config/spring")                     // local
Spring bean configurations
            ) {
             log.debug("Configuration or .class file change detected [" + operation + "]:
" + changedFile);
-            if (this.consoleOutput) {
+            if (CocoonReloadingListener.consoleOutput) {
                 System.out.println("RCL [" + operation + "]: " + changedFile);
             }
             reload = true;
         } else {
             log.debug("Other file change detected, no reload [" + operation + "]: " + changedFile);
 // any other file change
         }
+    }
+
+    public static void enableConsoleOutput() {
+        CocoonReloadingListener.consoleOutput = true;
     }
 
     public static synchronized boolean isReload() {

Modified: cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/tools/rcl/wrapper/servlet/ReloadingServlet.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/ReloadingServlet.java?rev=635835&r1=635834&r2=635835&view=diff
==============================================================================
--- cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/tools/rcl/wrapper/servlet/ReloadingServlet.java
(original)
+++ cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/tools/rcl/wrapper/servlet/ReloadingServlet.java
Tue Mar 11 00:49:12 2008
@@ -28,7 +28,7 @@
 /**
  * This servlet builds a classloading sandbox and runs another servlet inside
  * that sandbox. The purpose is to use the reloading classloader to load the
- * 
+ *
  * <p>
  * This servlet propagates all initialisation parameters to the sandboxed
  * servlet, and requires the parameter <code>servlet-class</code>.
@@ -49,7 +49,7 @@
     public void init(ServletConfig config) throws ServletException {
         super.init(config);
         this.config = config;
-        
+
         String servletName = config.getInitParameter("servlet-class");
         if (servletName == null) {
             throw new ServletException("ReloadingServlet: Init-Parameter 'servlet-class'
is missing.");
@@ -86,6 +86,8 @@
         final ClassLoader old = Thread.currentThread().getContextClassLoader();
         try {
             Thread.currentThread().setContextClassLoader(ReloadingClassloaderManager.getClassLoader(this.config.getServletContext()));
+
+            CocoonReloadingListener.enableConsoleOutput();
             this.servlet.service(request, response);
         } catch(Throwable t) {
             t.printStackTrace();

Modified: cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/tools/rcl/wrapper/servlet/ReloadingServletFilter.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/ReloadingServletFilter.java?rev=635835&r1=635834&r2=635835&view=diff
==============================================================================
--- cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/tools/rcl/wrapper/servlet/ReloadingServletFilter.java
(original)
+++ cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-webapp-wrapper/src/main/java/org/apache/cocoon/tools/rcl/wrapper/servlet/ReloadingServletFilter.java
Tue Mar 11 00:49:12 2008
@@ -47,10 +47,11 @@
             try {
                 Thread.currentThread().setContextClassLoader(ReloadingClassloaderManager.getClassLoader(this.context));
 
+                CocoonReloadingListener.enableConsoleOutput();
                 this.filter.doFilter(request, response, chain);
             } finally {
                 Thread.currentThread().setContextClassLoader(old);
-            }            
+            }
         }
     }
 



Mime
View raw message