cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robin Green" <gree...@hotmail.com>
Subject [PATCH] Performance fix to call hasChanged for XSP pages
Date Mon, 03 Apr 2000 14:08:30 GMT
IMO this is a bug, though only a performance bug - XSPPage implements 
Changeable, but the javadocs for Changeable say:

public boolean hasChanged(java.lang.Object context)

"...This method is guaranteed to be called after at least a single call to 
any production methods getStream or getDocument."

But if you put a hasChanged method in an XSP page, it is never called 
(AFAIK). Here is the fix:

diff -u -r1.17 XSPProcessor.java
--- xml-cocoon/src/org/apache/cocoon/processor/xsp/XSPProcessor.java    
2000/03/30 00:37:18     1.17
+++ xml-cocoon/src/org/apache/cocoon/processor/xsp/XSPProcessor.java    
2000/04/03 13:03:03
@@ -534,7 +534,22 @@
   }

   public boolean hasChanged(Object context) {
-    return true;
+
+    if (!(context instanceof HttpServletRequest))
+      return true;               // Can't interpret context
+
+    HttpServletRequest request = (HttpServletRequest) context;
+    String filename = Utils.getBasename(request, servletContext);
+
+    // Get page from Cocoon cache
+    PageEntry pageEntry = (PageEntry) this.store.get(filename);
+
+    // New page?
+    if (pageEntry == null) return true;
+
+    // NOT pageEntry.hasChanged ()! We are calling the hasChanged method
+    // of the XSP page itself.
+    return pageEntry.getPage ().hasChanged (context);
   }

   public String getStatus() {

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com


Mime
View raw message