cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefano Mazzocchi <stef...@apache.org>
Subject Re: [PATCH] Performance fix to call hasChanged for XSP pages
Date Mon, 03 Apr 2000 20:49:30 GMT
Robin Green wrote:
> 
> 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

Great patch!!!

Thanks, I applied it right away.

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<stefano@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------


Mime
View raw message