cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject svn commit: r160920 - cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/servlet/CocoonServlet.java
Date Mon, 11 Apr 2005 16:19:12 GMT
Author: sylvain
Date: Mon Apr 11 09:19:10 2005
New Revision: 160920

URL: http://svn.apache.org/viewcvs?view=rev&rev=160920
Log:
Fix order of dispose and create when reloading Cocoon (there were some exceptions in Quartz
and EHCacheStore)

Modified:
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/servlet/CocoonServlet.java

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/servlet/CocoonServlet.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/servlet/CocoonServlet.java?view=diff&r1=160919&r2=160920
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/servlet/CocoonServlet.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/servlet/CocoonServlet.java Mon
Apr 11 09:19:10 2005
@@ -1056,7 +1056,12 @@
         }
 
         // Get the cocoon engine instance
-        getCocoon(request.getPathInfo(), request.getParameter(Constants.RELOAD_PARAM));
+        
+        if (reloadCocoon(request.getPathInfo(), request.getParameter(Constants.RELOAD_PARAM)))
{
+            disposeCocoon();
+            initLogger();
+            createCocoon();
+        }
 
         // Check if cocoon was initialized
         if (this.cocoon == null) {
@@ -1371,6 +1376,12 @@
      */
     private synchronized void createCocoon()
     throws ServletException {
+        
+        // Recheck that we need to create the cocoon object. It can have been created by
+        // a concurrent invocation to this method.
+        if (this.cocoon != null) {
+            return;
+        }
 
         /* HACK for reducing class loader problems.                                     */
         /* example: xalan extensions fail if someone adds xalan jars in tomcat3.2.1/lib */
@@ -1405,7 +1416,6 @@
             ContainerUtil.initialize(c);
             this.creationTime = System.currentTimeMillis();
 
-            disposeCocoon();
             this.cocoon = c;
         } catch (Exception e) {
             if (getLogger().isErrorEnabled()) {
@@ -1493,7 +1503,7 @@
      * Gets the current cocoon object.  Reload cocoon if configuration
      * changed or we are reloading.
      */
-    private void getCocoon(final String pathInfo, final String reloadParam)
+    private boolean reloadCocoon(final String pathInfo, final String reloadParam)
     throws ServletException {
         if (this.allowReload) {
             boolean reload = false;
@@ -1516,11 +1526,10 @@
                 }
                 reload = true;
             }
-
-            if (reload) {
-                initLogger();
-                createCocoon();
-            }
+            
+            return reload;
+        } else {
+            return false;
         }
     }
 



Mime
View raw message