cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gkossakow...@apache.org
Subject svn commit: r582629 - in /cocoon/trunk/core/cocoon-sitemap: cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/SitemapSource.java cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/InvokeContext.java
Date Sun, 07 Oct 2007 13:39:19 GMT
Author: gkossakowski
Date: Sun Oct  7 06:39:19 2007
New Revision: 582629

URL: http://svn.apache.org/viewvc?rev=582629&view=rev
Log:
Moved management of ObjectModel to cocoon: protocol if it's used. This fixes various errors
with disappearing values from OM when cocoon: protocol is used.
The side-effect of this hack is that values could be visible outside their scope in some rare
cases. I haven't found any good way to avoid it due to complicated flow in SitemapSource.

Modified:
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/SitemapSource.java
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/InvokeContext.java

Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/SitemapSource.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/SitemapSource.java?rev=582629&r1=582628&r2=582629&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/SitemapSource.java
(original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/SitemapSource.java
Sun Oct  7 06:39:19 2007
@@ -26,11 +26,12 @@
 
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.Processor;
 import org.apache.cocoon.ResourceNotFoundException;
-import org.apache.cocoon.components.source.impl.SitemapSourceInfo;
 import org.apache.cocoon.components.source.util.SourceUtil;
+import org.apache.cocoon.el.objectmodel.ObjectModel;
 import org.apache.cocoon.environment.Environment;
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.environment.internal.EnvironmentHelper;
@@ -98,6 +99,9 @@
     private SourceResolver sourceResolver;
 
     private String mimeType;
+    
+    //if we touched (marked) new OM we will need to do a clean up work
+    boolean touchedOM = false;
 
     /**
      * Construct a new object
@@ -208,6 +212,17 @@
         } catch (Exception e) {
             throw new SourceException("Exception during processing of " + this.systemId,
e);
         } finally {
+            if (touchedOM) {
+                //Because of complicated flow of this source it must maintain the cleaness
of OM on its own
+                ObjectModel newObjectModel;
+                try {
+                    newObjectModel = (ObjectModel)manager.lookup(ObjectModel.ROLE);
+                } catch (ServiceException e) {
+                    throw new RuntimeException("Couldn't look up Object Model", e);
+                }
+                newObjectModel.cleanupLocalContext();
+                touchedOM = false;
+            }
             // Unhide wrapped environment output stream
             this.environment.setOutputStream(null);
             this.needsRefresh = true;
@@ -265,6 +280,12 @@
             this.processed = true;
             this.pipelineDescription = this.processor.buildPipeline(this.environment);
             this.environment.setURI(this.pipelineDescription.prefix, this.pipelineDescription.uri);
+            
+            //Because of complicated flow of this source it must maintain the cleaness of
OM on its own
+            ObjectModel newObjectModel = (ObjectModel)manager.lookup(ObjectModel.ROLE);
+            newObjectModel.markLocalContext();
+            touchedOM = true;
+            manager.release(newObjectModel);
 
             String redirectURL = this.environment.getRedirectURL();
             if (redirectURL == null) {
@@ -354,6 +375,17 @@
         } catch (Exception e) {
             throw new SAXException("Exception during processing of " + this.systemId, e);
         } finally {
+            if (touchedOM) {
+                //Because of complicated flow of this source it must maintain the cleaness
of OM on its own
+                ObjectModel newObjectModel;
+                try {
+                    newObjectModel = (ObjectModel)manager.lookup(ObjectModel.ROLE);
+                } catch (ServiceException e) {
+                    throw new SAXException("Couldn't look up Object Model", e);
+                }
+                newObjectModel.cleanupLocalContext();
+                touchedOM = false;
+            }
             this.needsRefresh = true;
         }
     }

Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/InvokeContext.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/InvokeContext.java?rev=582629&r1=582628&r2=582629&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/InvokeContext.java
(original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/InvokeContext.java
Sun Oct  7 06:39:19 2007
@@ -231,7 +231,11 @@
         final String sitemapObjectModelPathPrefix = "sitemap";
         final String sitemapObjectModelNamedPathPrefix = sitemapObjectModelPathPrefix + "/$named$";
         
-        newObjectModel.markLocalContext();
+        //if cocoon: protocol is used the isBuildingPipelineOnly() is true that means pipeline
going to be set up 
+        //but not executed at the same time therefore it must be cocoon: protocol that takes
responsibility for 
+        //maintaining OM's cleaness 
+        if (!isBuildingPipelineOnly())
+        	newObjectModel.markLocalContext();
         
         this.mapStack.add(map);
 
@@ -294,7 +298,11 @@
         Object name = this.mapToName.get(map);
         this.mapToName.remove(map);
         this.nameToMap.remove(name);
-        this.newObjectModel.cleanupLocalContext();
+        //if cocoon: protocol is used the isBuildingPipelineOnly() is true that means pipeline
going to be set up 
+        //but not executed at the same time therefore it must be cocoon: protocol that takes
responsibility for 
+        //maintaining OM's cleaness 
+        if (!isBuildingPipelineOnly())
+        	this.newObjectModel.cleanupLocalContext();
     }
 
     /**



Mime
View raw message